You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by BenXS <bx...@yahoo.co.uk> on 2010/08/17 15:53:48 UTC

How to let ONE bean listen on MULTIPLE Topics? SpringXML config in activemq.xml

I setup a Bean which currently listens successfully to exactly ONE Topic
"montopic20".
The SpringXML setup for this bean in activemq.xml is as shown below.

How can I let the same Bean listen to multiple different topics in parallel?
In other words: Which minimal changes do I have to apply to the SpringXML
config
below to listen e.g. to a second topic "montopic35" as well?

Can I simply add a second <constructor-arg /> ?

Or do I really have to setup a bean twice with full SpingXML declaration
again?

Ben

    <bean id="jmsContainer"
class="org.springframework.jms.listener.SimpleMessageListenerContainer">
      <property name="autoStartup" value="true"/>
      <property name="connectionFactory" ref="myConnectionFactory"/>
      <property name="destination" ref="myDestination"/>
      <property name="messageListener" ref="myMessageListener"/>
      <property name="acceptMessagesWhileStopping" value="true"/>
    </bean>
    
    <bean id="myConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
      <property name="brokerURL" value="tcp://localhost:61616"/>
    </bean>
    <bean id="myDestination"
class="org.apache.activemq.command.ActiveMQTopic">
      <constructor-arg value="montopic20"/>
    </bean>
    <bean id="myMessageListener" class="mPackage.MyMessageListener">       
      <property name="appName" value="My Application"/>
    </bean>

-- 
View this message in context: http://old.nabble.com/How-to-let-ONE-bean-listen-on-MULTIPLE-Topics--SpringXML-config-in-activemq.xml-tp29449265p29449265.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to let ONE bean listen on MULTIPLE Topics? SpringXML config in activemq.xml

Posted by Gary Tully <ga...@gmail.com>.
use a comma separated list of destination names in the singular
constructor-arg to the topic should do it, it will form a composite
destination. see:
http://activemq.apache.org/composite-destinations.html

something like:
<bean id="myDestination"
 class="org.apache.activemq.command.ActiveMQTopic">
      <constructor-arg value="montopic20,montopic21,montopic22"/>
</bean>

On 17 August 2010 14:53, BenXS <bx...@yahoo.co.uk> wrote:
>
> I setup a Bean which currently listens successfully to exactly ONE Topic
> "montopic20".
> The SpringXML setup for this bean in activemq.xml is as shown below.
>
> How can I let the same Bean listen to multiple different topics in parallel?
> In other words: Which minimal changes do I have to apply to the SpringXML
> config
> below to listen e.g. to a second topic "montopic35" as well?
>
> Can I simply add a second <constructor-arg /> ?
>
> Or do I really have to setup a bean twice with full SpingXML declaration
> again?
>
> Ben
>
>    <bean id="jmsContainer"
> class="org.springframework.jms.listener.SimpleMessageListenerContainer">
>      <property name="autoStartup" value="true"/>
>      <property name="connectionFactory" ref="myConnectionFactory"/>
>      <property name="destination" ref="myDestination"/>
>      <property name="messageListener" ref="myMessageListener"/>
>      <property name="acceptMessagesWhileStopping" value="true"/>
>    </bean>
>
>    <bean id="myConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>      <property name="brokerURL" value="tcp://localhost:61616"/>
>    </bean>
>    <bean id="myDestination"
> class="org.apache.activemq.command.ActiveMQTopic">
>      <constructor-arg value="montopic20"/>
>    </bean>
>    <bean id="myMessageListener" class="mPackage.MyMessageListener">
>      <property name="appName" value="My Application"/>
>    </bean>
>
> --
> View this message in context: http://old.nabble.com/How-to-let-ONE-bean-listen-on-MULTIPLE-Topics--SpringXML-config-in-activemq.xml-tp29449265p29449265.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com