You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by MaximeBelanger <ma...@uquebec.ca> on 2012/07/16 17:18:56 UTC

problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Hello,

I am not sure if this is an ActiveMQ issue, but my search so far as turned
up empty, so I have to start somewhere.
I am trying to setup a DefaultMessageListenerContainer using an ActiveMq
Durable subscriber (ActiveMQ 5.6.0), and Atomikos as TX manager for JTA,
configuring everything through Spring. I need to specify a clientId on the
connection for the durable subscriber. This is my config:
	<bean
		class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		<property name="connectionFactory" ref="jmsListenerConnectionFactory" />
		<property name="concurrentConsumers" value="1" />
		<property name="destinationName" value="topic.name" />
		<property name="durableSubscriptionName" value="durable.name" />
		<property name="subscriptionDurable" value="true" />
		<property name="messageListener" ref="integrationMdp" />
		<property name="transactionManager" ref="JtaTransactionManager" />
		<property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE" />
		<property name="pubSubDomain" value="true" />
		<property name="sessionTransacted" value="true" />
		<property name="clientId" value="msgListener" />
	</bean>

	<bean id="jmsListenerConnectionFactory"
class="com.atomikos.jms.AtomikosConnectionFactoryBean">
		<property name="uniqueResourceName" value="ActiveMQXAListener"/>
		<property name="maxPoolSize" value="1"/>
		<property name="xaConnectionFactory">
			<bean class="org.apache.activemq.ActiveMQXAConnectionFactory">
				<property name="brokerURL" value="${jms.brokerURL}"  />
				<property name="userName" value="${jms.username}" />
				<property name="password" value="${jms.password}" />
			</bean>
		</property>
		<property name="localTransactionMode" value="false"></property>
	</bean>

If I do this, I will get the following exception:

[org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] WARN 
com.atomikos.jms.AbstractJmsProxy  - Failed to create durable
TopicSubscriber: null 
javax.jms.JMSException: You cannot create a durable subscriber without
specifying a unique clientID on a Connection
	at
org.apache.activemq.ActiveMQConnection.checkClientIDWasManuallySpecified(ActiveMQConnection.java:1255)
	at
org.apache.activemq.ActiveMQSession.createDurableSubscriber(ActiveMQSession.java:1295)

On the other hand, if I set the clientId on the connectionFactory, I get the
following:

[org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] WARN 
com.atomikos.jms.AbstractJmsProxy  - Could not create an XASession on the
javax.jms.XAConnectionFactory's XAConnection - check if your JMS backend is
configured for XA? 
javax.jms.InvalidClientIDException: Broker: localhost - Client: msgListener
already connected from tcp://127.0.0.1:57501
	at
org.apache.activemq.broker.region.RegionBroker.addConnection(RegionBroker.java:223)
	at
org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:85)
[...]
[org.springframework.jms.listener.DefaultMessageListenerContainer#0-1] WARN 
com.atomikos.jms.AbstractJmsProxy  - Error delegating 'createSession' call
to JMS driver 
javax.jms.InvalidClientIDException: Broker: localhost - Client: msgListener
already connected from tcp://127.0.0.1:57501
	at
org.apache.activemq.broker.region.RegionBroker.addConnection(RegionBroker.java:223)
	at
org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:85)
[...]


I seem to be caught in a catch-22 type problem here... Anyone had success
with this kind of config?

Thanks for your help,
Max

--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Posted by csi <ch...@yahoo.com>.
Thanks, I'll give that a try.



--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049p4657907.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Posted by vtapadia <va...@gmail.com>.
Just for the sake of everyone, I was able to get the issue resolved by adding
a additional bean

    @Bean(initMethod = "recoverResource")
    public ActiveMQResourceManager resourceManager() {
        ActiveMQResourceManager resourceManager = new
ActiveMQResourceManager();
        resourceManager.setConnectionFactory(connectionFactory());
        resourceManager.setTransactionManager(transactionManager());
        resourceManager.setResourceName(resourceManagerName);
        return resourceManager;
    }

Hope this helps others also in the future.



--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049p4700481.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Posted by vtapadia <va...@gmail.com>.
Hi Max,

Very old issue, but I am facing the exact same issue.

The solution you have provided I guess removes the XA capabilities.

Did you get it to work?

Varesh



--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049p4700192.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Posted by MaximeBelanger <ma...@uquebec.ca>.
Hi Chris,

no I never got any answers. So I ended up using the activeMq connection
factory instead of the Atomikos one, like so:

<bean id="jmsListenerConnectionFactory"
class="org.apache.activemq.ActiveMQXAConnectionFactory">
		<property name="brokerURL" value="${jms.brokerURL}" />
		<property name="userName" value="${jms.username}" />
		<property name="password" value="${jms.password}" />
		<property name="clientID" value="msgListener" />
	</bean>

That solved the problem for the moment being, although I have not completed
load tests and various JMS transaction exception tests, so I'm not 100% sure
this will work...
Please share any success or failures on your behalf with this setup.

Max



--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049p4657906.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: problem configuring durable subscriber with Spring and Atomikos (XA issue?)

Posted by csi <ch...@yahoo.com>.
I seem to have the same problem .. did you get any answers or figure it out?

Thanks,

Chris



--
View this message in context: http://activemq.2283324.n4.nabble.com/problem-configuring-durable-subscriber-with-Spring-and-Atomikos-XA-issue-tp4654049p4657905.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.