Questions tagged [msmq-wcf]

WCF can communicate directly with MSMQ, whether you intend to read/write from/to MSMQ. WCF also allows the plug-in of MSMQ-like COM/COM+ components.

MSMQ is a Windows platform specific technology to guarantee the delivery of messages to a specific destination. WCF has 2 bindings which can read/write directly to/from MSMQ, without the need for specific code - just configuration.

WCF offers 2 binding strategies:

  • NetMsmqBinding - a push/pull directly to/from MSMQ
  • MsmqIntegrationBinding - a push/pull directly from a COM/COM+ component

To use MSMQ and WCF together is actually very straight forward. From inserting into MSMQ, you do not even need a concrete implementation on the WCF. A simple example would be:

namespace WcfServices
{
  // Interface is only required for MSMQ
  [ServiceContract]
  public interface ISendTextService
  {
    [OperationContract(IsOneWay=true)]
    public void Write(string text);
  }
}

To hook this up to a configuration file you would do:

<configuration>
  <system.serivceModel>
     <bindings>
       <netMsmqBinding>
         <!-- exactlyOnce="false" allows you send multiple MSMQ messages from the channel instance -->
         <binding exactlyOnce="false">

           <!-- Remove security requirements for testing -->
           <security mode="None"/>
         </binding>           
     </bindings>
     <client>
       <!-- Address format requires net.msmq prefix and no $ sign -->
       <!-- The MSMQ 'test' must also already exist for this to work -->
       <endpoint address="net.msmq://localhost/private/test"
                 binding="netMsmqBinding"
                 contract="WcfService.ISendTextService" />    
     </client>
   </system.serviceModel>
 </configuration>

This deals with the sending to MSMQ. A client app can then do something like:

public class TestMsmq
{
  static void Main(string[] args)
  {
     var factory = new ChannelFactory<WcfService.ISendTextService>();
     var channel = factory.CreateChannel();

     // This is required so that they can all be committed together
     using(var scope = new TransactionScope(TransactionScopeOption.Required))
     {
        channel.SendText("Hello, world!");
        channel.SendText("Hello, world! - Part 2");
        channel.SendText("Hello, world! - Part 3");
        scope.Complete();
     }
  }
}
55 questions
2
votes
2 answers

Using Windows Services to process MSMQ messages via WCF

We have a solution where we are picking the messages using Windows Service. The Windows Service fires every after 2 minutes and retrieves the MSMQ message to pass it to a Web Service. Can I create a WCF service which will automatically picks up…
VeryBiztalker
2
votes
1 answer

Logging WCF Requests and Responses using Message Inspectors on an MSMQ Endpoint

I'm working on a WCF service layer, which utilizes message inspectors for logging request and reply soap messages. Here's the inspector, stripped of irrelevant code; public class ServiceInspectorBehavior : Attribute, IDispatchMessageInspector,…
tdgtyugdyugdrugdr
  • 786
  • 4
  • 13
  • 31
2
votes
0 answers

"netMsmqBinding" lost message

I have a WF4 that its hosted in a Windows Service and works with netMsmqBinding. All works well when the service its started. The service read the private queue and process the message okey. The problem is when the windows services is stop, i…
2
votes
1 answer

How to receive MSMQ Messages

Whats the best way to receive MSMQ messages. I used the following code, but after receiving MSMQ messages not getting removed in Queue var msgEnumerator = myQueue.GetMessageEnumerator2(); var messages = new…
Vishnu
  • 1,029
  • 4
  • 14
  • 24
2
votes
0 answers

WCF subscriber stops polling message from queue randomly

I am using wondows 2008 standard OS.we have private queue ,in that message is published by another application.And we have WCF subscriber to poll the message from private queue and deliver to another system... after some time WCF…
samash
  • 757
  • 2
  • 15
  • 32
2
votes
1 answer

Net.Msmq Binding Not Picking Up Messages in Queue as soon as the application pool gets recycled

"when the application pool is "alive" the service picks up the messages correctly, but as soon as the application pool gets recycled (because of timeout or any other reason), the service stops picking up the messages, that just sit in the…
user1935938
  • 113
  • 2
  • 7
2
votes
2 answers

MSMQ, WCF and robustness

Not being an expert on MSMQ or WCF, I have read up a fair bit about it and it sounds and looks great. I am trying to develop something, eventually but first some theory, which needs to be robust and durable. MSMQ I guess will be hosted on a…
Ahmed ilyas
  • 5,722
  • 8
  • 44
  • 72
1
vote
1 answer

About LAB EntLib, MSMQ and WCF

I am not really comfortable with this subject since I always wrote my own logger until now. I have a WCF REST web service. This service needs to log information from errors to who uses it and when. To do so the Logging Application Block from…
lollancf37
  • 1,105
  • 3
  • 15
  • 27
1
vote
0 answers

How to detect empty msmq queue and close wcf service host after that

I have windows service which periodically create servicehost with msmq binding. I want to process all or defined number o messages from msmq and gracefully close the host. But i cant find simple solution when to close a host or how to detect empty…
Jan Strnad
  • 63
  • 2
  • 6
1
vote
2 answers

How to make WCF service run continuously in IIS?

I've written a small wcf service application which reads messages from msmq. And hosted the wcf service in IIS-7. THe issue is I can read the message only if I click on browse button from IIS. There is no client application which refers this service…
user2995902
  • 49
  • 1
  • 8
1
vote
0 answers

How to use MSMQ (windows) from nodejs(Linux) ?

I am trying to use MSMQ(windows) from nodejs(Linux). After searching I find a plugin node-msmq(https://www.npmjs.com/package/node-msmq). But this plugin only helps if the both are on same server. Any help or suggestion.
Tarun Nagpal
  • 690
  • 1
  • 8
  • 21
1
vote
3 answers

Read WCF MSMQ Message from C#

I used a WCF client to send msmq message to WCF Service, before WCF Service process the msmq message, I want to check the body of the message. After checking the content of msmq message body, I got below result. But, I failed to get the exact…
Edward
  • 28,296
  • 11
  • 76
  • 121
1
vote
1 answer

MSMQ: Does MSMQ guarantees sequential message passing?

After load testing, I found some packets are not sequential. it's a basic WCF service and client is continuously sending the request.
User
  • 17
  • 1
  • 6
1
vote
1 answer

Button click of .NET application needs to tell an external service to start processing from a queue (msmq)

I have an asp.net webforms application that users will be interacting with. When the user selects certain items from the site and clicks a button for processing. The webapp will add a message to msmq for each item the user selects. The part I am…
William Venice
  • 329
  • 2
  • 7
  • 16
1
vote
0 answers

Using WCF with MSMQ binding: How can I handle soap messages that exceed MSMQs 4MB message limit?

We have an integration scenario where we have to call a WCF service using an MSMQ queue (using WCFs netMsmqBinding). If I understand correctly, MSMQ has a 4MB limit on message size. So my question is: How do the WCF/MSMQ bits handle SOAP messages…
codeape
  • 97,830
  • 24
  • 159
  • 188