You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Ramit Arora <ra...@gmail.com> on 2008/03/21 21:50:01 UTC

Implementing failover for Net::Stomp

Hi,
I am using ActiveMQ 5.0.0. My application requires Perl publishers & Java
subscribers. Since HA is a necessity, I wish to implement failover
capability in the Net::Stomp client for Perl. 
I've already come up with a basic solution, but I am facing the following
problem:
I use the pipe broken signal to detect master broker failure from perl. The
pipe does not break until the master shuts down its Stomp connector. If I
abruptly shut down the master (power down or kill -9), then there is no
issue. But if I cleanly shutdown the master (^C), then the master does not
shut down its Stomp connector until it has done its cleanup. This normally
takes around 10secs. This results in the Perl client sending messages to the
broker for those crucial ten seconds. These messages are lost & not
delivered to the Java client.
Is there are any other way of detecting that the master is shutting down?
Perhaps something using the STOMP ERROR frame?

TIA,
Ramit 
-- 
View this message in context: http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16207964.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Implementing failover for Net::Stomp

Posted by Ramit Arora <ra...@gmail.com>.
Hello Dejan,
I had a look at the PHP client. I was following a similar approach, but the
major problem was that the ActiveMQ shutdown hook was enabled, which did not
let the socket close for around 10secs. Disabling it has made things a lot
better. Thanks for your time.

Regards,
Ramit

Dejan Bosanac wrote:
> 
> Hi Ramit,
> 
> you can take a look at how this functionality is implemented in PHP
> client (http://stomp.codehaus.org/PHP+Connectivity). Basically, you
> can detect that broker is down when you try to read/write from a
> socket and implement reconnection logic in those cases. BTW. error
> frames are sent to the client only in ActiveMQ 5.1 and in case you
> have sent receipt header with your command.
> 
> Cheers
> -- 
> Dejan Bosanac
> www.scriptinginjava.net
> 
> On Fri, Mar 21, 2008 at 11:35 PM, Ramit Arora <ra...@gmail.com>
> wrote:
>>
>>  Sure thing man, but I'll have to work this thing out first....
>>  I think it can be achieved if the broker sends the client an ERROR frame
>>  when it detects a shutdown in progress. My experiments show that the
>> broker
>>  currently does not send any notification to a Stomp client while
>> shutting
>>  down. Can someone from the development team confirm this? And would it
>> be
>>  possible for the broker to send a notification while shutting down to
>> Stomp
>>  clients so that failover can be implemented?
>>  Any other ideas for this will be greatly appreciated.
>>
>>  TIA,
>>  Ramit
>>
>>
>>
>>
>>  Llarian wrote:
>>  >
>>  > If you get this worked out, would you be willing to release your
>>  > Net::Stomp hacks?
>>  >
>>  > I'm desperatly needing HA for my perl publishers (and subscribers for
>> that
>>  > matter), but I don't have the hours to do it in house at the moment.
>>  >
>>  > -D
>>  >
>>  >> -----Original Message-----
>>  >> From: Ramit Arora [mailto:ramit.arora@gmail.com]
>>  >> Sent: Friday, March 21, 2008 1:50 PM
>>  >> To: users@activemq.apache.org
>>  >> Subject: Implementing failover for Net::Stomp
>>  >>
>>  >>
>>  >>
>>  >> Hi,
>>  >> I am using ActiveMQ 5.0.0. My application requires Perl
>>  >> publishers & Java
>>  >> subscribers. Since HA is a necessity, I wish to implement failover
>>  >> capability in the Net::Stomp client for Perl.
>>  >> I've already come up with a basic solution, but I am facing
>>  >> the following
>>  >> problem:
>>  >> I use the pipe broken signal to detect master broker failure
>>  >> from perl. The
>>  >> pipe does not break until the master shuts down its Stomp
>>  >> connector. If I
>>  >> abruptly shut down the master (power down or kill -9), then
>>  >> there is no
>>  >> issue. But if I cleanly shutdown the master (^C), then the
>>  >> master does not
>>  >> shut down its Stomp connector until it has done its cleanup.
>>  >> This normally
>>  >> takes around 10secs. This results in the Perl client sending
>>  >> messages to the
>>  >> broker for those crucial ten seconds. These messages are lost & not
>>  >> delivered to the Java client.
>>  >> Is there are any other way of detecting that the master is
>>  >> shutting down?
>>  >> Perhaps something using the STOMP ERROR frame?
>>  >>
>>  >> TIA,
>>  >> Ramit
>>  >> --
>>  >> View this message in context:
>>  >> http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp
>>  > -tp16207964s2354p16207964.html
>>  > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>  >
>>  >
>>  >
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16210250.html
>>
>>
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> Dejan Bosanac
> www.scriptinginjava.net
> 

-- 
View this message in context: http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16296589.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Implementing failover for Net::Stomp

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Ramit,

you can take a look at how this functionality is implemented in PHP
client (http://stomp.codehaus.org/PHP+Connectivity). Basically, you
can detect that broker is down when you try to read/write from a
socket and implement reconnection logic in those cases. BTW. error
frames are sent to the client only in ActiveMQ 5.1 and in case you
have sent receipt header with your command.

Cheers
-- 
Dejan Bosanac
www.scriptinginjava.net

On Fri, Mar 21, 2008 at 11:35 PM, Ramit Arora <ra...@gmail.com> wrote:
>
>  Sure thing man, but I'll have to work this thing out first....
>  I think it can be achieved if the broker sends the client an ERROR frame
>  when it detects a shutdown in progress. My experiments show that the broker
>  currently does not send any notification to a Stomp client while shutting
>  down. Can someone from the development team confirm this? And would it be
>  possible for the broker to send a notification while shutting down to Stomp
>  clients so that failover can be implemented?
>  Any other ideas for this will be greatly appreciated.
>
>  TIA,
>  Ramit
>
>
>
>
>  Llarian wrote:
>  >
>  > If you get this worked out, would you be willing to release your
>  > Net::Stomp hacks?
>  >
>  > I'm desperatly needing HA for my perl publishers (and subscribers for that
>  > matter), but I don't have the hours to do it in house at the moment.
>  >
>  > -D
>  >
>  >> -----Original Message-----
>  >> From: Ramit Arora [mailto:ramit.arora@gmail.com]
>  >> Sent: Friday, March 21, 2008 1:50 PM
>  >> To: users@activemq.apache.org
>  >> Subject: Implementing failover for Net::Stomp
>  >>
>  >>
>  >>
>  >> Hi,
>  >> I am using ActiveMQ 5.0.0. My application requires Perl
>  >> publishers & Java
>  >> subscribers. Since HA is a necessity, I wish to implement failover
>  >> capability in the Net::Stomp client for Perl.
>  >> I've already come up with a basic solution, but I am facing
>  >> the following
>  >> problem:
>  >> I use the pipe broken signal to detect master broker failure
>  >> from perl. The
>  >> pipe does not break until the master shuts down its Stomp
>  >> connector. If I
>  >> abruptly shut down the master (power down or kill -9), then
>  >> there is no
>  >> issue. But if I cleanly shutdown the master (^C), then the
>  >> master does not
>  >> shut down its Stomp connector until it has done its cleanup.
>  >> This normally
>  >> takes around 10secs. This results in the Perl client sending
>  >> messages to the
>  >> broker for those crucial ten seconds. These messages are lost & not
>  >> delivered to the Java client.
>  >> Is there are any other way of detecting that the master is
>  >> shutting down?
>  >> Perhaps something using the STOMP ERROR frame?
>  >>
>  >> TIA,
>  >> Ramit
>  >> --
>  >> View this message in context:
>  >> http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp
>  > -tp16207964s2354p16207964.html
>  > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>  >
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16210250.html
>
>
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

RE: Implementing failover for Net::Stomp

Posted by Ramit Arora <ra...@gmail.com>.
Sure thing man, but I'll have to work this thing out first....
I think it can be achieved if the broker sends the client an ERROR frame
when it detects a shutdown in progress. My experiments show that the broker
currently does not send any notification to a Stomp client while shutting
down. Can someone from the development team confirm this? And would it be
possible for the broker to send a notification while shutting down to Stomp
clients so that failover can be implemented?
Any other ideas for this will be greatly appreciated.

TIA,
Ramit


Llarian wrote:
> 
> If you get this worked out, would you be willing to release your
> Net::Stomp hacks?
> 
> I'm desperatly needing HA for my perl publishers (and subscribers for that
> matter), but I don't have the hours to do it in house at the moment.
> 
> -D
> 
>> -----Original Message-----
>> From: Ramit Arora [mailto:ramit.arora@gmail.com]
>> Sent: Friday, March 21, 2008 1:50 PM
>> To: users@activemq.apache.org
>> Subject: Implementing failover for Net::Stomp
>>
>>
>>
>> Hi,
>> I am using ActiveMQ 5.0.0. My application requires Perl
>> publishers & Java
>> subscribers. Since HA is a necessity, I wish to implement failover
>> capability in the Net::Stomp client for Perl.
>> I've already come up with a basic solution, but I am facing
>> the following
>> problem:
>> I use the pipe broken signal to detect master broker failure
>> from perl. The
>> pipe does not break until the master shuts down its Stomp
>> connector. If I
>> abruptly shut down the master (power down or kill -9), then
>> there is no
>> issue. But if I cleanly shutdown the master (^C), then the
>> master does not
>> shut down its Stomp connector until it has done its cleanup.
>> This normally
>> takes around 10secs. This results in the Perl client sending
>> messages to the
>> broker for those crucial ten seconds. These messages are lost & not
>> delivered to the Java client.
>> Is there are any other way of detecting that the master is
>> shutting down?
>> Perhaps something using the STOMP ERROR frame?
>>
>> TIA,
>> Ramit
>> --
>> View this message in context:
>> http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp
> -tp16207964s2354p16207964.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16210250.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Implementing failover for Net::Stomp

Posted by Ramit Arora <ra...@gmail.com>.
Hi Simon,
An async receives patch would be great. Thanks!
BTW, would it be possible for you to release a failover patch for
master/slave or broker networks? And transaction support would also be nice.

Thanks,
Ramit

Simon Wistow wrote:
> 
> On Fri, Mar 21, 2008 at 02:44:00PM -0700, Dylan Vanderhoof said:
>> If you get this worked out, would you be willing to release your 
>> Net::Stomp hacks?
> 
> The original author of the Net::Stomp client on CPAN doesn't work with 
> ActiveMQ any more and so has let it lapse. I had a word with him and I 
> can apply any patches and roll new releases if necessary.
> 
> I should check to see if this has been applied
> 
> http://issues.apache.org/activemq/browse/AMQ-978
> 
> as well and I should also finish off my asynchronous-receive patch and 
> merge that in too.
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp-tp16207964s2354p16296609.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Implementing failover for Net::Stomp

Posted by Simon Wistow <si...@thegestalt.org>.
On Fri, Mar 21, 2008 at 02:44:00PM -0700, Dylan Vanderhoof said:
> If you get this worked out, would you be willing to release your 
> Net::Stomp hacks?

The original author of the Net::Stomp client on CPAN doesn't work with 
ActiveMQ any more and so has let it lapse. I had a word with him and I 
can apply any patches and roll new releases if necessary.

I should check to see if this has been applied

http://issues.apache.org/activemq/browse/AMQ-978

as well and I should also finish off my asynchronous-receive patch and 
merge that in too.





RE: Implementing failover for Net::Stomp

Posted by Dylan Vanderhoof <Dy...@semaphore.com>.
If you get this worked out, would you be willing to release your Net::Stomp hacks?

I'm desperatly needing HA for my perl publishers (and subscribers for that matter), but I don't have the hours to do it in house at the moment.

-D

> -----Original Message-----
> From: Ramit Arora [mailto:ramit.arora@gmail.com]
> Sent: Friday, March 21, 2008 1:50 PM
> To: users@activemq.apache.org
> Subject: Implementing failover for Net::Stomp
>
>
>
> Hi,
> I am using ActiveMQ 5.0.0. My application requires Perl
> publishers & Java
> subscribers. Since HA is a necessity, I wish to implement failover
> capability in the Net::Stomp client for Perl.
> I've already come up with a basic solution, but I am facing
> the following
> problem:
> I use the pipe broken signal to detect master broker failure
> from perl. The
> pipe does not break until the master shuts down its Stomp
> connector. If I
> abruptly shut down the master (power down or kill -9), then
> there is no
> issue. But if I cleanly shutdown the master (^C), then the
> master does not
> shut down its Stomp connector until it has done its cleanup.
> This normally
> takes around 10secs. This results in the Perl client sending
> messages to the
> broker for those crucial ten seconds. These messages are lost & not
> delivered to the Java client.
> Is there are any other way of detecting that the master is
> shutting down?
> Perhaps something using the STOMP ERROR frame?
>
> TIA,
> Ramit
> --
> View this message in context:
> http://www.nabble.com/Implementing-failover-for-Net%3A%3AStomp
-tp16207964s2354p16207964.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.