activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Ruckstuhl <>
Subject Re: Real world example for CMS?
Date Mon, 19 Jan 2009 21:58:37 GMT

Hi Timothy

I'm now able to deal with connection interruptions on the sending side but
seem to get some problems on the receiving side (there are some partner that
simple just receive messages)

What I currently do is (in pseudocode)

Consumer c = session.createConsumer(SomeDestination)

while(true) {
    Message m = c.receiveTimeout(1Second)
    if(m != Void){

Now my problem seems to be that, "c.receive" doesn't throw an exception if
the connection is lost and therefore I'm not able to detect the lost

Thanks again for your helpful advice


Timothy Bish wrote:
>> Now to the second part of my question:
>> What is the recommended way to deal with multiple threads? Should I use
>> the
>> SessionPool? Or should I share one session and protect it? Any hints how
>> to
>> best deal with recreating the resources?
> We've made every attempt to make the classes in CMS thread safe, so you
> could share one session amongst many threads.  Probably the best thing
> todo is hide the actual CMS code behind some sort of Proxy object that
> you give to each of your threads that provides the functionality that
> they need to send their messages, then in the proxy you could monitor
> the Connection for exceptions using an exception listener and destroy
> and recreate all the resources that you did initially while locking
> something like a mutex that prevents your producers from publishing
> anything while you are reconnecting.  
> Once 3.0 is done all of that should become transparent to the user if
> they use the Failover Transport.  But until then you could do something
> like I described to make it work for now.  
> SessionPool is really only intended for use in the CMSTemplate code, not
> in your own code.
> Regards
> Tim.
> -- 
> Tim Bish

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message