activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <de...@nighttale.net>
Subject Re: One session for more consumers
Date Mon, 10 Oct 2011 08:16:13 GMT
Yes, you can create multiple consumers on a single session and reuse the
listener.

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Sat, Oct 8, 2011 at 9:45 AM, LFS <luks@spoluzaci.cz> wrote:

> Hello,
> I have question whether more Consumers can use one session? or I have
> create
> for each consumer new session? And one more question. Can I use one
> instance
> of MyMessageListener for each consumer? or I have create for each consumer
> new instance of MyMessageListener?
> For better idea this is segment of my code:
>
>     ..............
>     session = (ActiveMQSession) connection.createSession(transacted,
> Session.AUTO_ACKNOWLEDGE);
>    // Create the destinations and consumers
>            consumersFromTopic=new
> MessageConsumer[user.getUserfriends().size()];
>            for(int i=0; i<user.getUserfriends().size();i++){
>                User u=user.getUserfriends().get(i);
>                String subject = u.getName()+"sFriendsTopic";
>                Destination d=session.createTopic(subject);
>                MessageConsumer c=session.createConsumer(d);
>                consumersFromTopic[i]=c;
>            }
>
>            //Create messages listeners
>            MyListener = new MyMessageListener(session, user);
>            //Set messages listener to consumers
>            for(MessageConsumer consumer: consumersFromTopic){
>               consumer.setMessageListener(RQMListener);
>            }
> ...............
> Thanks
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/One-session-for-more-consumers-tp3884602p3884602.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message