You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Aleksi Kallio <al...@csc.fi> on 2012/02/06 09:51:18 UTC

How to create temporary topic without blocking?

Hi,

We have client apps connecting to our server environment using ActiveMQ, 
with failover enabled. Our users can have the app open on a laptop while 
moving from one network to another or to a completely unconnected place.

ActiveMQ does beautiful failover, keeping the system running between 
network connections. However there are certain cases when we would like 
to use our own "failover mechanism".

To do that, we would need to be able to check connection state or have 
an exception thrown when connection is not active. Now when you try to 
send a message and create a temporary reply topic without network 
connection it hangs on session.createTemporaryTopic().

How to not block on session.createTemporaryTopic() when the network is 
disconnected?

I tried setting useAsyncSend to true and checking 
connection.isTransportFailed() before calling createTemporaryTopic(), 
but neither of them helped.

Creating a throwaway thread for the send attempt is a solution, but a 
very crude one.

All the best,
Aleksi


Re: How to create temporary topic without blocking?

Posted by Aleksi Kallio <al...@csc.fi>.
Thanks! So there is no way to have both long and short timeouts in one 
connection?

I would like to keep the infinite failover, but then for certain API 
calls, have it fail immediately if connection is lost.


On 2012-02-06 17:06, Timothy Bish wrote:
> You need to use the Failover transport options to configure the
> transport to fail after some amount of time, the timeout option will let
> you do that, see:
>
> http://activemq.apache.org/failover-transport-reference.html
>
>
>
> On Mon, 2012-02-06 at 10:51 +0200, Aleksi Kallio wrote:
>> Hi,
>>
>> We have client apps connecting to our server environment using ActiveMQ,
>> with failover enabled. Our users can have the app open on a laptop while
>> moving from one network to another or to a completely unconnected place.
>>
>> ActiveMQ does beautiful failover, keeping the system running between
>> network connections. However there are certain cases when we would like
>> to use our own "failover mechanism".
>>
>> To do that, we would need to be able to check connection state or have
>> an exception thrown when connection is not active. Now when you try to
>> send a message and create a temporary reply topic without network
>> connection it hangs on session.createTemporaryTopic().
>>
>> How to not block on session.createTemporaryTopic() when the network is
>> disconnected?
>>
>> I tried setting useAsyncSend to true and checking
>> connection.isTransportFailed() before calling createTemporaryTopic(),
>> but neither of them helped.
>>
>> Creating a throwaway thread for the send attempt is a solution, but a
>> very crude one.
>>
>> All the best,
>> Aleksi
>>
>

Re: How to create temporary topic without blocking?

Posted by Timothy Bish <ta...@gmail.com>.
You need to use the Failover transport options to configure the
transport to fail after some amount of time, the timeout option will let
you do that, see:

http://activemq.apache.org/failover-transport-reference.html



On Mon, 2012-02-06 at 10:51 +0200, Aleksi Kallio wrote: 
> Hi,
> 
> We have client apps connecting to our server environment using ActiveMQ, 
> with failover enabled. Our users can have the app open on a laptop while 
> moving from one network to another or to a completely unconnected place.
> 
> ActiveMQ does beautiful failover, keeping the system running between 
> network connections. However there are certain cases when we would like 
> to use our own "failover mechanism".
> 
> To do that, we would need to be able to check connection state or have 
> an exception thrown when connection is not active. Now when you try to 
> send a message and create a temporary reply topic without network 
> connection it hangs on session.createTemporaryTopic().
> 
> How to not block on session.createTemporaryTopic() when the network is 
> disconnected?
> 
> I tried setting useAsyncSend to true and checking 
> connection.isTransportFailed() before calling createTemporaryTopic(), 
> but neither of them helped.
> 
> Creating a throwaway thread for the send attempt is a solution, but a 
> very crude one.
> 
> All the best,
> Aleksi
> 

-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/