user3671959
user3671959

Reputation: 11

Spring JMS Publish/Susbcriber configuration to IBM Webpshere MQ

Searching in the web I found a lot of example of how spring have to be configured (file.xml) for publish/subscriber mode for active MQ but I need how beans need to be configured for Websphere MQ Anyone have been configured both product with success?

Upvotes: 1

Views: 314

Answers (1)

Ahmad Y. Saleh
Ahmad Y. Saleh

Reputation: 3349

The following is bean definition of a Websphere MQ ConnectionFactory:

<bean id="wmqConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
    <property name="queueManager">
        <value>QUEUE_MANAGER</value>
    </property>
    <property name="hostName">
        <value>127.0.0.1</value>
    </property>
    <property name="port">
        <value>1414</value>
    </property>
    <property name="transportType">
        <value>1</value>
    </property>
    <property name="channel">
        <value>SYSTEM.DEF.SVRCONN</value>
    </property>
</bean>

you may need to provide a username and password, and you can accomplish that by wrapping it in a UserCredentialsConnectionFactoryAdapter:

<bean id="userCredentialsAdapter" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="wmqConnectionFactory" />
    <property name="username" value=" " />
    <property name="password" value=" " />
</bean>

It is also a good idea to wrap it in a CachingConnectionFactory, so that sessions, consumers and producers are cached, this wrapper also switches the auto-recovery to true:

<bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory" ref="userCredentialsAdapter"/>
    <property name="cacheConsumers" value="true" />
    <property name="cacheProducers" value="true" />
    <property name="sessionCacheSize" value="10" />
</bean>

with this configuration, you can use the cachingConnectionFactory with whatever bean you need.

Upvotes: 2

Related Questions