activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From LFS <l...@spoluzaci.cz>
Subject One session for more consumers
Date Sat, 08 Oct 2011 07:45:18 GMT
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
View raw message