ActiveMQ durable subscription
To connect to an ActiveMQ topic in a durable way, an additional parameter called durableSubscriptionName has to be specified in the connection URI. However, there is a limitation that from the side of one client, only one subscriber can be connected simultaneously to a given topic using a given durable subscription name. For example:
jms:jndi-topic:dynamicTopics/newBooksTopic.topic?jndiInitialContextFactory=org.apache.activemq.jndi.Active
MQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61616&durableSubscriptionName=mySubscription
The JMS specification prohibits two or more subscribers using the same durableSubscriptionName and durableSubscriptionClientId to be connected to the same topic simultaneously. When using one WSDL for creation, for example provider and consumer (or multiple consumers), which is a usual situation, this becomes a problem, because the same JMS connection URI is shared among multiple participants. This means that if durableSubscriptionName or durableSubscriptionClientId is specified in the URI in the WSDL, all the participants will use the same parameters and only one of the participants will be allowed to connect to the topic by a message broker.
To manage this situation, a special Talend ESB feature called DurableSubscriptionFeature has been created. The feature is part of the transport-jms library, so no other dependencies are needed. The feature allows to specify durableSubscriptionName and durableSubscriptionClientId parameters individually for a participant. Here is an example of how to configure it in Spring configuration:
<bean id="subscriberDurableSubscriptionFeature" class="org.talend.esb.transport.jms.DurableSubscriptionFeature">
<property name="durableSubscriptionClientId" value="someClientId"/>
<property name="durableSubscriptionName" value="someSubscriptionName"/>
</bean>
<jaxws:endpoint xmlns:library="http://services.talend.org/demos/Library/1.0"
id="LibraryNotificationReceiver"
address="jms:jndi-topic:dynamicTopics/newBooksTopic.topic?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&
;jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:61616&durableSubscriptionName=someAnotherName"
serviceName="library:LibraryProvider" endpointName="library:LibraryTopicPort"
implementor="org.talend.services.demos.client.LibraryNotificationReceiverImpl">
<jaxws:features>
<ref bean="subscriberDurableSubscriptionFeature"/>
</jaxws:features>
</jaxws:endpoint>
Note that to make DurableSubscriptionFeature work, the durableSubscriptionName parameter should be specified in the URI. The value of the parameter will be replaced with the one provided by the feature.