Atomikos Forum |
|
Another behavior I noticed is if I put my listener inside of an XA transaction it never pulls messages off of the queue and acts like there are no messages. If I remove the transactional advice on the listener it behaves as expected.
Is this a known issue? I'm using MQ 7 server and client jars (7.0.1) on Spring tcServer. My connection factory looks like this: <bean id="atomikosBillConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean"> <property name="xaConnectionFactory" ref="billConnectionFactory"/> <property name="uniqueResourceName" value="Bill_MQSeries_XA_RMI"/> <property name="maxPoolSize" value="5"/> </bean> My listener is setup like this: <bean id="myListener" class="com.railinc.tcServer.bill.services.listener.BillListenerImpl"> <property name="jaxbCtx" ref="billJaxbContext"/> <property name="updateDao" ref="billUpdateDao"/> <property name="invalidBillKey" value="789"/> </bean> <bean id="msgListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"> <property name="delegate" ref="myListener"/> <property name="defaultListenerMethod" value="onMessage"/> </bean> <bean id="myContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="autoStartup" value="true"/> <property name="connectionFactory" ref="atomikosBillConnectionFactory"/> <property name="destination" ref="billServQueue"/> <property name="messageListener" ref="msgListener"/> <property name="sessionTransacted" value="true"/> <property name="transactionManager" ref="txManager"/> <property name="receiveTimeout" value="1000"/> <property name="transactionTimeout" value="9000"/> <property name="transactionName" value="HELLO_TX"/> </bean> I tried applying a typical default transactional policy: <tx:advice id="txAdvice" transaction-manager="txManager"> <!-- the transactional semantics... --> <tx:attributes> <!-- all methods starting with 'get' are read-only --> <tx:method name="get*" read-only="true" /> <!-- other methods use the default transaction settings (see below) --> <tx:method name="*" /> </tx:attributes> </tx:advice> When I run this, with messages on the queue, it never pulls the message from the queue. Is this a known issue or am I screwing something up? Once I remove the transactional stuff from the listener it pulls messages like it should. Thanks, John
Guy sorry I don't think your container will work for us :(
A couple of issues: #1 (the real show stopper) as far as I can tell from looking at your source, this will spawn new un-managed threads :(, I don't see anyway to give it a hook to a thread pool or other container based thread manager #2 - another pain point, although I could probably sub class the listener container to fix this is lack of some other methods for JMX support for starting/stopping listeners (e.g. isStarted or isStopped methods and a startOnStartup kind of flag for container based configuration of listener startup). #3 - a minimal pain point I could easily live without, but would be nice, no POJO message listener support :D, sorry spoiled by Spring. I'll continue trying to research the listener failure with our MQ team. Thanks John
Hi John,
Thanks for the feedback! Re point 3: actually, we have had POJO message listener support - even before Spring had its own :-) Just check our MessageDrivenContainer - you merely need to inject your MessageListener POJO. And: it is faster than Spring's built-in message listeners (at least according to our users). Regarding the points 1 and 2: we'd be glad to incorporate any feature requests you might have. Thanks, Guy
Ok, you talked me into it, so I tried out the atomikos MessageDrivenContainer, but I am still getting the same results :(, no messages are being pulled off the queue.
I am using the com.ibm.mq.jms.MQXAConnectionFactoryFactory in my server config. My Spring config is: <bean id="atomikosBillListenConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean"> <property name="xaConnectionFactory" ref="billListenerConnectionFactory"/> <property name="uniqueResourceName" value="Bill_Listen_MQSeries_XA_RMI"/> <property name="maxPoolSize" value="5"/> <property name="localTransactionMode" value="false"/> </bean> (uniqueResourceName is definitely unique) <bean id="msgListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"> <property name="delegate" ref="myListener"/> <property name="defaultListenerMethod" value="onMessage"/> </bean> <bean id="myContainer" class="com.atomikos.jms.extra.MessageDrivenContainer"> <property name="atomikosConnectionFactoryBean" ref="atomikosBillListenConnectionFactory"/> <property name="transactionTimeout" value="3000"/> <property name="destination" ref="billServQueue"/> <property name="messageListener" ref="msgListener"/> <property name="poolSize" value="3"/> </bean> I feel like I'm setup correctly. A couple of points: #1. I can send just fine using the same queue connection factory and XA #2. If I set the localTransactionMode to true on the listener Queue Connection Factory it works and pulls the messages. Ugh thanks John
An update on my progress,
I moved the queue connection factory & queue into my spring config and pulled all the tomcat settings out (no more user transaction and no more lifecycle listener). I'm not configuring my QCF & queue and Atomikos completely in my Spring Config and it WORKs!!! I still am using a data source configured in Tomcat and that works too. Then my next step I pulled the QCF & queue definition out and put it back in my server.xml. Not it fails again :(. For some reason when I pull a connection out of a QCF defined in my server instead of locally in my spring config it fails to pull messages at all. Weird.
Nevermind!
I had accidentally put MQ 6.0 client jars in my server lib instead of 7.0, while experimenting and forgot to remove them. Now with 7.0 MQ jars its working!!!
Ok I figured out my entire problem!
I had followed both the spring integration and tomcat integration docs and was firing up 2 transaction managers, one by the tomcat lifecycle listener and another by the spring config :D I completely removed all the tomcat stuff (the listener and the user transaction factory) and left just the spring config. Now data sources defined in server.xml (atomikos data source bean) and queue connection factories (defined server.xml but wrapped in atomikos in spring config) both work! Thanks John |