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
9
votes
2 answers

Python running MessageQueue.Peek via win32com, how to get timeout right?

For starters, I would like to say if anyone can help here, you are incredible. General Question My Python program needs to interact with MSMQ. Basically, I want to peek at a queue, specifying a timeout if there's nothing in the queue. However,…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
7
votes
3 answers

WCF MSMQ binding with an IIS service - how to instantiate the service?

I have a WCF service with netMsmqBinding. My client can send messages to my queue, and when the service is running it retrieves messages from the queue as expected. If the service is not running, messages received are queued until the service…
Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
7
votes
1 answer

WCF & MSMQ & TransactionScope long process

I am trying to develop a WCF service that take care of hundreds downloads and conversion together. I have been initialized MSMQ with a transaction queue that receive messages from an ASP.NET web application. My question after a long research on…
Giuseppe
  • 281
  • 3
  • 7
6
votes
2 answers

How to implement Message Queuing Solution

I have a scenario where about 10 different messages will need to be enqueued and then dequeued / processed. One subscriber will need all 10 messages, but another will only need 8 of the 10 messages. I am trying to understand what the best way is…
scarpacci
  • 8,957
  • 16
  • 79
  • 144
6
votes
2 answers

WCF Net.Msmq Service occasionally faults

I have a self-hosted WCF service (runs inside a windows service). This service listens for messages on an MSMQ. The service is PerCall, and Transactional running on Windows 2008 R2, .NET 4.0, MSMQ 5.0. Once every couple of weeks the service will…
JNappi
  • 1,495
  • 1
  • 14
  • 24
4
votes
3 answers

WCF + MSMQ 4 : Who moves a message from retry queue back to the application queue?

This is a simple question, but I was not able to find an answer. Suppose my message is placed to the retry queue (who creates the retry queue? Is it a WCF or a MSMQ service?) After 5 minutes (that's my retry delay) that message gets back to the…
THX-1138
  • 21,316
  • 26
  • 96
  • 160
4
votes
0 answers

WCF MSMQ - SRMP on a different port

I have an application that pushes messages to a WCF endpoint via an MSMQ. In dev, it works well when using the MSMQ protocol, but in production I need to do a network hop. I need to set this up so the queue pushes to the WCF endpoint over HTTP on a…
Ev.
  • 7,109
  • 14
  • 53
  • 87
4
votes
1 answer

Alternative to MSMQ for use in Windows Store Applications

I recently discovered that NetMsmqBinding is not supported in Windows Store Apps, are there any alternative ways to implement a similar system of queuing messages to a host machine from a tablet? Thank you!
MJ33
  • 859
  • 12
  • 25
4
votes
3 answers

Immediate and scheduled business transactions - MSMQ/NServiceBus/MS Sql Service Broker/Windows Task Scheduler?

I have this scenario, guys- A typical large-scale CMS application in which the following business transactions appear: Users publish content immediately. Users schedule content to be published. Automatic process runs ,say, in 10 minutes interval,…
Arman
  • 5,136
  • 3
  • 34
  • 36
3
votes
1 answer

Proper place for initialization code in non-HTTP WCF service hosted in IIS/WAS?

It is my understanding that a WCF service configured for net.msmq will not run as an HttpApplication when hosted in IIS/WAS, which means you don't get the events in Global (Application_Start being the important one). Am I correct in this…
sliderhouserules
  • 3,415
  • 24
  • 32
3
votes
1 answer

WF4 calling WCF Service

I'm having a problem trying to get a workflow (WF4) to call a long running WCF service and then resume processing when the WCF service completes. The diagram below gives a rough outline of what I'm trying to achieve. If you could point me at any…
user321271
  • 53
  • 6
3
votes
2 answers

How to increase number of messages that can be stored in MSMQ

We have a number of MSMQ queues throughout our system, both private and public queues. Sometimes a windows service that reads from a queue will crash, and so messages will build up in that queue. Once the queue gets to a certain size (maybe 60K…
Justin
  • 17,670
  • 38
  • 132
  • 201
3
votes
1 answer

Log Buffering Through MSMQ to WCF Web Service

I have an interesting situation on my hands. For a few years now we've had a WCF service that runs on an IIS box on our network that we use for logging. Applications use basicHttpBinding to send log messages and it logs them to a database. Most of…
omatase
  • 1,551
  • 1
  • 18
  • 42
2
votes
2 answers

How do I set the Priority on client side of MSMQ message sent to a WF Service activated via MQ

I have a WCF activated WorkFlow Service (XAMLX) setup (hosted using WorkflowServiceHost). This WCF WebService has a 'NetMsMqBinding' binding and a net.msmq based endpoint which is used by clients to schedule operations. On the client side, I've…
bhavinb
  • 3,278
  • 2
  • 28
  • 26
2
votes
2 answers

MSMQ between WCF services in a load balanced enviroment

I'm thinking of adding a queue function in a product based on a bunch of WCF services. I've read some about MSMQ, first I thought that was what I needed but I'm not sure and are considering to just put the queue in a database table. I wonder if…
1
2 3 4