activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Tully <gary.tu...@gmail.com>
Subject Re: durable topic subscriber using spring and atomikos
Date Thu, 13 Jan 2011 11:10:14 GMT
You cannot use a connection pool if you are setting the client Id on a
connection factory because a durable sub can only be active on a
single connection at a time.

A durable subscription is tied to a well known clientId and
subscriptionName, message are stored based on this identity and it
needs to be unique so that the ordering and delivery can be
guaranteed.

It is possible to configure the container to specify the clientId on
an individual connection basis such that you don't set it on the
factory?

What is your use case for using a durable subscription and a connection pool.

Some more detail in an answer from a while back:
http://osdir.com/ml/java.activemq.user/2005-05/msg00141.html



On 11 January 2011 22:53, softweave <janee@softweave.com> wrote:
>
> I wrote a topic listener that works fine as a non-durable topic subscriber. I
> want to convert it to a durable topic subscriber, but am running into
> problems.
>
> This portion of the spring configuration sets up the topic listener:
>
>        <bean id="xaFactory"
> class="org.apache.activemq.ActiveMQXAConnectionFactory">
>        <property name="brokerURL" value="tcp://localhost:61616"/>
> <!--     <property name="clientID" value="xaEventListenerConnection" />-->
>        </bean>
>
>        <bean id="atomikosConnectionFactoryBean"
>                class="com.atomikos.jms.AtomikosConnectionFactoryBean"
>                init-method="init" destroy-method="close">
>          <property name="uniqueResourceName" value="ACTIVEMQ_BROKER"/>
>          <property name="xaConnectionFactory" ref="xaFactory" />
>          <property name="maxPoolSize" value="1"/>
>        </bean>
>
>        <bean id="eventHandler" class="com.med.XAEventHandler">
>                <property name="eventRepository" ref="eventRepository"/>
>        </bean>
>
>        <!-- a class that implements javax.jms.MessageListener -->
>        <bean id="eventListener" class="com.med.XAEventListener">
>                <property name="eventHandler" ref="eventHandler"/>
>        </bean>
>
>        <!--  initialize the destination -->
>    <bean id="eventTopic" class="org.apache.activemq.command.ActiveMQTopic"
>>
>          <constructor-arg value="ChangeDataEvents.Topic" />
>    </bean>
>
>        <!-- Configure the session pool for JMS.
>        This will also manage the transactions for incoming messages. -->
>        <bean id="eventListenerContainer"
>                class="com.atomikos.jms.extra.MessageDrivenContainer"
>                init-method="start" destroy-method="stop">
>                <property name="atomikosConnectionFactoryBean"
> ref="atomikosConnectionFactoryBean" />
>            <property
> name="transactionTimeout"><value>120</value></property>
>            <property name="destination"><ref bean="eventTopic"/></property>
>            <property name="messageListener"><ref
> bean="eventListener"/></property>
>        <property name="noLocal" value="true"/>
>        <property name="poolSize" value="50"/>
> <!--     <property name="subscriberName" value="xaEventListener"/>-->
>        </bean>
>
> If I uncomment out the clientID and subscriberName properties, it gets the
> following error:
>
> WARN-[2011-01-07 22:39:20,262][Thread-5][Error delegating 'start' call to
> JMS driver
> javax.jms.InvalidClientIDException: Broker: localhost - Client:
> xaEventListenerConnection already connected from /127.0.0.1:2299
>        at
> org.apache.activemq.broker.region.RegionBroker.addConnection(RegionBroker.java:243)
>        at
> org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:85)
>        at
> org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:78)
>        at
> org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:85)
>        at
> org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:85)
>        at
> org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:91)
>        at
> org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:696)
>        at
> org.apache.activemq.broker.jmx.ManagedTransportConnection.processAddConnection(ManagedTransportConnection.java:83)
>        at
> org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:137)
>        at
> org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:311)
>        at
> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:185)
>        at
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
>        at
> org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
>        at
> org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:228)
>        at
> org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
>        at
> org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
>        at
> org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
>        at java.lang.Thread.run(Unknown Source)
> ][-atomikos][com.atomikos.diagnostics.Slf4jConsole.println(Slf4jConsole.java:107)]
> WARN-[2011-01-07 22:39:20,278][Thread-5][MessageConsumerSession: Error in
> JMS thread
>
> How do I prevent this?
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/durable-topic-subscriber-using-spring-and-atomikos-tp3209848p3209848.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://blog.garytully.com
http://fusesource.com

Mime
View raw message