Muthukumar
Muthukumar

Reputation: 9579

Websphere MQ - Topic Subscription with multiple consumers

I have a micro-service which subscribes to a topic in WebSphere MQ. The subscription is managed and durable. I explicitly set the subscription name, so that it can be used to connect back to the queue, after recovering from any micro service failure. The subscription works as expected.

But I might have to scale up the micro service and run multiple instances. In this case I will end up with having multiple consumers to the same topic. But here it fails with error 2429 : MQRC_SUBSCRIPTION_IN_USE. I am not able to run more than one consumer to the topic subscription. Note : A message should be sent only to one of the consumers.

Any thought ?

IBM Websphere Version : 7.5 I use the C-client API to connect to the MQ.

Upvotes: 2

Views: 2064

Answers (1)

JoshMc
JoshMc

Reputation: 10642

When using a subscriber what you describe is only supported via the IBM MQ Classes for JMS API. In v7.0 and later you can use Cloned subscriptions (this is a IBM extension to the JMS spec), in addition in MQ v8.0 and later you can alternately use Shared subscriptions which is part of the JMS 2.0 spec. With these two options, multiple subscribers can be connected to the same subscription and only one of them will receive each published message.


UPDATE 20170710

According to this APAR IV96489: XMS.NET DOESN'T ALLOW SHARED SUBSCRIPTIONS EVEN WHEN CLONESUP PROPERTY IS ENABLED, XMS.NET is also supposed to support Cloned subscriptions but due to a defect this is will not be supported until 8.0.0.8 or 9.0.0.2 or if you request the IFIX for the APAR above.


You can accomplish something similar with other APIs like C by converting your micro-service to get from a queue instead of subscribing to a topic.

To get the published messages to the queue you have two options:

  1. Setup a administrative subscription on the queue manager. You can do this a few different ways. The example below would be using a MQSC command.

    DEFINE SUB('XYZ') TOPICSTR('SOME/TOPIC') DEST(SOME.QUEUE)

  2. Create a utility app that can open a queue and create a durable subscription with that provided queue, the only purpose of this app would be to subscribe and unsubscribe a provided queue, it would not be used to consume any of the published messages.


Using the above method, each published message can only be read (GET) from the queue by one process or thread.

Upvotes: 8

Related Questions