You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Steve.V." <st...@sas.com> on 2014/04/21 20:37:03 UTC

How do you destroy orphaned consumers on the server/broker?

I have a client application that use the REST API, and by default is
specifies a clientId parameter on the URL. When my client terminates
abruptly without a request having the "&action=unsubscribe" parameter, then
a consumer can be orphaned on the server/broker.  Since an orphaned consumer
can cause major trouble, I would like to know how to clean-up orphaned
consumers on the server without having to bounce the server.

I posted this question in the Users forum back on 02Feb2013, but did not get
any replies:
http://activemq.2283324.n4.nabble.com/How-do-you-close-orphaned-consumers-sometimes-left-when-REST-API-clients-are-killed-tp4662681.html

If anyone knows how to destroy orphaned consumers, please let me know.

Cheers,
Stephen Vincent



-----
Stephen Vincent
--
View this message in context: http://activemq.2283324.n4.nabble.com/How-do-you-destroy-orphaned-consumers-on-the-server-broker-tp4680431.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How do you destroy orphaned consumers on the server/broker?

Posted by artnaseef <ar...@artnaseef.com>.
Monitoring is very important for ActiveMQ, so it's good to hear.  I've used
JMX and Jolokia for that purpose.  The advisories are useful for that as
well.



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-do-you-destroy-orphaned-consumers-on-the-server-broker-tp4680431p4699301.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How do you destroy orphaned consumers on the server/broker?

Posted by artnaseef <ar...@artnaseef.com>.
It can be done, but may be tricky.  If the client is using the clientId
setting, then unsubscribe should work - just pass the same clientId. 
Otherwise, it's a little harder - the consumer is connected to the HTTP
session.  As long as the session matches (I believe that's a cookie and
possibly combined with username), then the unsubscribe should work.

Another approach here is to use the oneShot setting on the consumer so the
internal consumer created by the servlet does not stick around.

Note that I consider this to be an anti-pattern - that is, creating
consumers inside AMQ and leaving them around.  However, it is necessary as a
media-adapter for REST.  Generally the best practice is to use a separate
REST service that connects to ActiveMQ and consumes as-needed.



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-do-you-destroy-orphaned-consumers-on-the-server-broker-tp4680431p4699293.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How do you destroy orphaned consumers on the server/broker?

Posted by nickmich <ni...@gmail.com>.
Does anyone know how to do this purely through the request? I'm currently
working on a Python client using the requests library, and my consumers are
still getting orphaned in AMQ after session.close() 



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-do-you-destroy-orphaned-consumers-on-the-server-broker-tp4680431p4699286.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How do you destroy orphaned consumers on the server/broker?

Posted by Timothy Bish <ta...@gmail.com>.
On 04/21/2014 02:37 PM, Steve.V. wrote:
> I have a client application that use the REST API, and by default is
> specifies a clientId parameter on the URL. When my client terminates
> abruptly without a request having the "&action=unsubscribe" parameter, then
> a consumer can be orphaned on the server/broker.  Since an orphaned consumer
> can cause major trouble, I would like to know how to clean-up orphaned
> consumers on the server without having to bounce the server.
>
> I posted this question in the Users forum back on 02Feb2013, but did not get
> any replies:
> http://activemq.2283324.n4.nabble.com/How-do-you-close-orphaned-consumers-sometimes-left-when-REST-API-clients-are-killed-tp4662681.html
>
> If anyone knows how to destroy orphaned consumers, please let me know.
>
> Cheers,
> Stephen Vincent
>
>
>
> -----
> Stephen Vincent
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/How-do-you-destroy-orphaned-consumers-on-the-server-broker-tp4680431.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Use JMX to get a DurableSubscriptionViewMBean for that consumer and call 
destroy()

https://github.com/apache/activemq/blob/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.java

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