java - Producer and Consumer in Spring Jms use same connection factory? -


i have component reads messages queue , meanwhile sends processed messages queue. therefore, component both message consumer , producer. configuring them, need connection factory consuming , connection factory producing. here part of spring configuration.

<!-- configuration listener --> <bean id="mdc.targetconnectionfactory4listener" class="com.tibco.tibjms.tibjmsconnectionfactory">       <property name="serverurl" value="tcp://localhost:7222"/> </bean>  <bean id="mdc.connectionfactory4listener" class="org.springframework.jms.connection.usercredentialsconnectionfactoryadapter">       <property name="targetconnectionfactory" ref="mdc.targetconnectionfactory"/>     <property name="username" value="admin" />     <property name="password" value="test" /> </bean>  <bean id="mdc.inputqueue" class="com.tibco.tibjms.tibjmsqueue">       <constructor-arg>           <value>input_queue</value>       </constructor-arg>   </bean>  <bean id="mdc.jmscontainer" class="org.springframework.jms.listener.defaultmessagelistenercontainer">       <property name="connectionfactory" ref="mdc.connectionfactory4listener" />       <property name="destination" ref="mdc.inputqueue" />       <property name="messagelistener" ref="mdc.messagereceiver" />       ...... </bean>  <!-- configuration sender --> <bean id="mdc.targetconnectionfactory4sender" class="com.tibco.tibjms.tibjmsqueue">       <property name="serverurl" value="tcp://localhost:7222"/> </bean>  <bean id="mdc.cachingconnectionfactory" class="org.springframework.jms.connection.cachingconnectionfactory">     <property name="targetconnectionfactory" ref="mdc.targetconnectionfactory4sender" />     <property name="sessioncachesize" value="50" /> </bean>  <bean id="mdc.outputqueue" class="com.tibco.tibjms.tibjmsqueue">       <constructor-arg>           <value>discovery_queue</value>       </constructor-arg>   </bean>  <bean id="mdc.jmstemplate" class="org.springframework.jms.core.jmstemplate">     <property name="connectionfactory" ref="mdc.cachingconnectionfactory" /> </bean>  <bean id="mdc.messagereceiver" class="net.siemens.discovery.queue.queuemessagelistener">     <property name="jmstemplate" ref="mdc.jmstemplate" />       <property name="destination" ref="mdc.outputqueue" />     ...... </bean> 

the 2 queues running on same ems server. has opinions configurations: can configured using 1 connectionfactory , 2 instances not necessary. however, if use 1 connectionfactory instance, instance used both in defaultmessagelistenercontainer , cachingconnectionfactory (further used in jmstemplate). don't know whether have impact on each other.

it normal use single connection factory; unusual use 2 factories in case.

in fact, if want perform jmstemplate operations on container thread , want interactions run in transaction (sessiontransacted = true in container), must use same connection factory. allows roll if there's exception.

when using caching connection factory in listener container should set connection factory cacheconsumers false. (see this answer more information.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -