1
votes

Requirement: Build a .NET based application that can reads messages at regular interval from a IBM Websphere Message Queue and save those messages in database

My solution: I created a windows service application that polls the Message Queue at certain interval and process the data.

Problem with polling is that application process is delayed by the polling interval. I cannot set the interval too short as I am not sure how much data there will be in the Message Queue and how long it will take to process.

Question: What would be better way to process data from a WebSphere Message Queue using .NET? How will I be able to process the data as soon as arrive in Message queue?

2
Why does the application not follow the usual pattern of GET with wait? - T.Rob
@T.Rob Not sure what you meant. The application currently waits for 30s and then gets and process message from MQ. - fahmi
Question says "application process is delayed by the polling interval". Normally, the application issues a GET and specifies a WAIT interval. When a message arrives, there is zero delay because the app is waiting on it. If the WAIT expires, the app gets RC=2033 and loops back with another GET and WAIT. However, if an application issues a GET with no WAIT, then sleeps for 30 seconds, there is a long delay while the app is asleep. - T.Rob

2 Answers

1
votes

What you need is asynchronous messaging. This works by registering a callback, which the MQ client will then invoke when a message is available. Take a look at the Knowledge Center page:

http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q023050_.htm

1
votes

You need to use IBM Message Service Client for .NET (a.k.a. XMS .NET). This client provides message listener feature (basically a callback as Tim mentioned above). Message listener will be invoked when a message that matches consumer selection criteria arrives in a queue.

If you are using MQ v7.1 or above, then XMS .NET is installed with MQ client. If you are at lower version, then you need to download IA9H support pack. You will need to reference IBM.XMS assembly in your application. Samples are shipped with product to demonstrate a number features including Message Listener.

Look at SimpleAsyncConsumer.cs sample shipped with product for details.