Maybe I am mixing things, if so, please let me know.
I want to provide a set of services through WCF regarding messages (this is an example). In this set, I will have the sendMessage service and the receiveMessage service.
For sendMessage, I want to use MSMQ, so the user can send a message to 100,000 to other users, and this will be processed in the background.
For receiving Message, I do not want to use MSMQ because I want the user to be serviced when he makes a request and receives a response (MSMQ, in this case, is turned on).
I use this code to run my host in the sample application
static void Main(string[] args) { using (ServiceHost host = new ServiceHost(typeof(Service), new Uri[] { new Uri("net.msmq://localhost/private/loadqueue"), new Uri("http://localhost:8383/") })) { host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true }); NetMsmqBinding binding = new NetMsmqBinding(); binding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None; binding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None; binding.ExactlyOnce = false; host.AddServiceEndpoint( typeof(IContract), binding, string.Empty); host.AddServiceEndpoint( typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); host.Open(); Console.WriteLine("service running"); Console.ReadLine(); } }
The contract is as follows
[ServiceContract(SessionMode=SessionMode.Allowed)] [DeliveryRequirements(QueuedDeliveryRequirements = QueuedDeliveryRequirementsMode.Allowed)] public interface IContract { [OperationContract(IsOneWay = true)] void SendData(string msg); }
When the client calls the SendData service, the message is sent to the queue, and after that it is consumed by the service.
I would like to create a second service that receives a message directly from the client (no queue in the middle).
The client will have only one web link, and if it calls service.SendData (), the message is sent to the queue, and if the client calls service.NetMethod (), the service receives the message directly. Thus, the client-side developer will be transparent if the service uses the queue or not, and I can group services related to their functions, rather than mechanisms. Is it possible to do?
Thanks Oscar