Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF / WebService to act as Listener for MQ Message?

Perhaps I am barking up the wrong tree - but I have a set of services (WebAPI and WCF) that use WebSphere MQ to interact with other systems.

This works without issue - until I now need to find a way of listening for messages on one of the queues.

Is this even possible, or do I need to go down the windows Service route?

like image 245
BlueChippy Avatar asked May 10 '15 11:05

BlueChippy


3 Answers

You could write a Windows service that is continually calling MQ Get on the queue, and invokes a WCF service to process the message. Or you could write a trigger program (a console application) that MQ will launch for you when a message arrives, that invokes the WCF service.

like image 117
Mike Stockdale Avatar answered Oct 17 '22 08:10

Mike Stockdale


I might be just better at googling than you are, but I seem to have found the answer here.

Seems you want to load the IBM binding configuration in you app.config

<extensions>
  <bindingElementExtensions>
    <add name="IBM.XMS.WCF.SoapJmsIbmTransportChannel" 
           type="IBM.XMS.WCF.SoapJmsIbmTransportBindingElementConfig, IBM.XMS.WCF, Version=7.5.0.0, Culture=neutral, PublicKeyToken=8c7c0be90afcd8ba"/>
  </bindingElementExtensions>
</extensions>

Then you can add a WebSphere WCF binding config.

<bindings>
  <customBinding>
    <binding name="CustomBinding_WMQ">
      <textMessageEncoding messageVersion="Soap11" />
      <IBM.XMS.WCF.SoapJmsIbmTransportChannel />
    </binding>
  </customBinding>
</bindings>
like image 2
Aron Avatar answered Oct 17 '22 08:10

Aron


Your problem can be broken down into two distinct elements:

  1. How to integrate MQ with a WCF-supported transport
  2. How to expose a WCF endpoint over this transport

To address the first issue, you should look at the MQ-MSMQ bridge which ships with Host Integration Server up to version 2009 (not R2), which allows you to have messages delivered to MQSeries queues forwarded to local MSMQs in windows. Although this feature is deprecated it's probably the easiest way if you have a MSDN license.

Another way of addressing this issue is to use BizTalk server which ships with a MQSeries adapter, though unless you're using BizTalk currently in your enterprise I would avoid.

The last way you could do this is to program directly against the MQSeries .NET client libraries or via the XMS client.

If you manage to solve the first issue then solving the second one is easy enough. You can expose one way WCF service operations over msmq transport by using the netMsmqBinding (for WCF on both ends), or msmqIntegrationBinding for clients using System.Messaging or native msmq COM libraries.

This in-effect acts as a listener service, with messages being handled by the service operation.

like image 1
tom redfern Avatar answered Oct 17 '22 09:10

tom redfern