Captain CYD
Captain CYD

Reputation: 1

Spring Websphere MQ 7 : how to subscribe on an administratively subscription?

I am using spring with Websphere MQ for doing a publish / subscribe. After several tests, i can :

  1. create a non durable subcription on a topic by API and consume messages
  2. create a durable subcription on a topic by API and consume messages

My goal now, it is to subscribe on an administratively subscription. With Websphere Explore, I have created my administratively subscription associated to a local queue -> OK

In my application, I want to suscribe to this administratively subscription. I am using the same configuration like the step 2 above :

<!-- producer ibmConnectionFactory -->
<bean id="ibmConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
    <property name="transportType" value="1" />
    <property name="connectionNameList" value="myHostname(1414)" />
    <property name="channel" value="CH_CYD_CON" />
    <property name="clientId" value="client1" />
</bean>

 <bean id="cachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="ibmConnectionFactory" />
</bean>

 <bean id="emailListener" class="com.myapp.jms.listener.EmailListener">
</bean>

<bean id="smsListener" class="com.myapp.jms.listener.SMSListener">
</bean>

 <jms:listener-container connection-factory="singleConnectionFactory" destination-type="durableTopic" transaction-manager="transactionManager"
    acknowledge="transacted" destination-resolver="jmsDestResolver" container-type="default" client-id="client1">
    <jms:listener id="newsEmailListener" destination="News" ref="emailListener" method="onMessage" subscription="EmailSubscription" />
    <jms:listener id="newsSmsListener" destination="News" ref="smsListener" method="onMessage" subscription="SMSSubscription" />
</jms:listener-container>

If i am not create the subscription, this configuration is going to create the subscription in the queue manager with this name :

JMS:<Queue Manager>:<Client ID>:<subscription name>

And, I can consume messages.

Now, if I have created the subscription in Websphere Explorer, I thinked the same configuration it is going to work. In fact, the result is I have no errors during execution, but I can'nt consume the messages.

I am following this tutorial for created my differents objects in my MQ Manager.

So, my questions are :

I can connect straight to the queue associated to the administratively subscription, but I think it is not a good solution.

Upvotes: 0

Views: 804

Answers (2)

Calanais
Calanais

Reputation: 1590

As JMS is being used underneath the Spring framework to talk to MQ the issue is that JMS is designed to primarily work with fully managed subscriptions, the creation of which is initiated by the client code.

It is possible to used administrative subscriptions from JMS - the key is creating the subscription name in Explorer correctly to match what the MQ JMS client is creating.

Information is available in this technote to describe the syntax. It can be helpful as well to look at the name of the dynamic subscription that JMS creates in the case that you have working. If there happened to be one of the same name already - JMS would re-open that subscription.

There is an RFE open to make this easier to use - please feel free to add your voice.

Upvotes: 1

Attila Repasi
Attila Repasi

Reputation: 1830

The purpose of the administrative subscription is to allow applications capable only to read queues to receive messages published on a topic. Such a subscription is supposed to be created by the MQ administrator kind of permanently to allow the application reading the target queue to get the messages published on the topic the subscription is for.

If your application is capable to subscribe directly to topics, you don't need an administrative subscription to receive messages.

You can create administrative subscriptions programmatically via PCF messages ( http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.adm.doc/q087050_.htm ), but you don't need to.

Upvotes: 0

Related Questions