You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Simone Giacomelli <in...@simone.pro> on 2013/10/08 19:35:43 UTC

Reject queue message if no Consumer is available

I'm using ActiveMq in a request/response configuration.

I was wondering if it is possible to reject Producer message if no Consumer
is available.
I did search the forum, googled very much, but found nothing close to my
scenario.

My implementation is about a RPC mechanism. So if the requestor (Producer)
does not have a response (from Consumer) it will hang until a timeout
happen.
I would like to remove the timeout and give a (semi) immediate exception to
the Producer.

Is it possible through a Broker Filter?  Or by any other means?

Please, tell me if I missed something useful from my explanation, I'll be
glad to add further information.

I'm using ActiveMq 5.8
Non persistent queue
I'm using it with Debian Linux and Ms Windows
Jdk 1.7_21
In embedded mode.

best regards
Simone Giacomelli

PS I was successfully able to create a customized authentication plugin.
And another plugin to reject Consumer if Destination have already one
Consumer
I love ActiveMQ :)

Re: Reject queue message if no Consumer is available

Posted by Jako <in...@simone.pro>.
Paul, it is exactly what I was looking for.
Is there a way to recover the examples in the link you pointed out?

To clarify better my model I should have written this link 
http://activemq.apache.org/how-should-i-implement-request-response-with-jms.html

In relation to the comment in the page
>//message to the server you would presumably want to associate the
correlation ID with this
>//message somehow...a Map works good

I followed this example and implemented it with an association between
request and response.

Johan, what do you mean with 'exclusive consumers'? I'm using queues, so I'm
sure that the message will be consumed only by one consumer (in opposition
to topics)

To tell the truth, I would prefer to implement a rejection, in other words,
change the broker behavior.
Anyway It is good to have a solution in the client side of the
implementation.

Thanks,
Simone




--
View this message in context: http://activemq.2283324.n4.nabble.com/Reject-queue-message-if-no-Consumer-is-available-tp4672396p4672437.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Reject queue message if no Consumer is available

Posted by Christian Posta <ch...@gmail.com>.
Good point. I don't endorse it, but if there are use cases that require,
you can implement it w/ Advisory messages which would let you know whether
there is a consumer. Could also do w/ JMX mbean lookups, but advisory
messages would probably be best.


On Tue, Oct 8, 2013 at 2:08 PM, Paul Gale <pa...@gmail.com> wrote:

> Simone's requirements do seem similar to what's described in the
> section entitled: "Complete Example: Producer that only Produces when
> there is a Consumer" (speaking of which all the code examples are
> missing) here:
>
> http://activemq.apache.org/cms/handling-advisory-messages.html
>
> Not endorsing it, but it does sound very similar.
>
> Thanks,
> Paul
>
> On Tue, Oct 8, 2013 at 3:31 PM, Johan Edstrom <se...@gmail.com> wrote:
> > Like Christian stated it doesn't make a whole lot of sense.
> > You don't need a plugin to reject either, use exclusive consumers.
> >
> > On Oct 8, 2013, at 1:28 PM, Christian Posta <ch...@gmail.com>
> wrote:
> >
> >> Well, the whole point of queueing messages is to be able to
> asynchronously
> >> deliver messages so that consumers don't have to be aware of producers
> and
> >> vice versa. That is, if there are no consumers, the producers should
> still
> >> be able to work. Maybe you can describe the problem you're trying to
> solve
> >> a little better?
> >>
> >>
> >> On Tue, Oct 8, 2013 at 10:35 AM, Simone Giacomelli <in...@simone.pro>
> wrote:
> >>
> >>> I'm using ActiveMq in a request/response configuration.
> >>>
> >>> I was wondering if it is possible to reject Producer message if no
> Consumer
> >>> is available.
> >>> I did search the forum, googled very much, but found nothing close to
> my
> >>> scenario.
> >>>
> >>> My implementation is about a RPC mechanism. So if the requestor
> (Producer)
> >>> does not have a response (from Consumer) it will hang until a timeout
> >>> happen.
> >>> I would like to remove the timeout and give a (semi) immediate
> exception to
> >>> the Producer.
> >>>
> >>> Is it possible through a Broker Filter?  Or by any other means?
> >>>
> >>> Please, tell me if I missed something useful from my explanation, I'll
> be
> >>> glad to add further information.
> >>>
> >>> I'm using ActiveMq 5.8
> >>> Non persistent queue
> >>> I'm using it with Debian Linux and Ms Windows
> >>> Jdk 1.7_21
> >>> In embedded mode.
> >>>
> >>> best regards
> >>> Simone Giacomelli
> >>>
> >>> PS I was successfully able to create a customized authentication
> plugin.
> >>> And another plugin to reject Consumer if Destination have already one
> >>> Consumer
> >>> I love ActiveMQ :)
> >>>
> >>
> >>
> >>
> >> --
> >> *Christian Posta*
> >> http://www.christianposta.com/blog
> >> twitter: @christianposta
> >
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Reject queue message if no Consumer is available

Posted by Paul Gale <pa...@gmail.com>.
Simone's requirements do seem similar to what's described in the
section entitled: "Complete Example: Producer that only Produces when
there is a Consumer" (speaking of which all the code examples are
missing) here:

http://activemq.apache.org/cms/handling-advisory-messages.html

Not endorsing it, but it does sound very similar.

Thanks,
Paul

On Tue, Oct 8, 2013 at 3:31 PM, Johan Edstrom <se...@gmail.com> wrote:
> Like Christian stated it doesn't make a whole lot of sense.
> You don't need a plugin to reject either, use exclusive consumers.
>
> On Oct 8, 2013, at 1:28 PM, Christian Posta <ch...@gmail.com> wrote:
>
>> Well, the whole point of queueing messages is to be able to asynchronously
>> deliver messages so that consumers don't have to be aware of producers and
>> vice versa. That is, if there are no consumers, the producers should still
>> be able to work. Maybe you can describe the problem you're trying to solve
>> a little better?
>>
>>
>> On Tue, Oct 8, 2013 at 10:35 AM, Simone Giacomelli <in...@simone.pro> wrote:
>>
>>> I'm using ActiveMq in a request/response configuration.
>>>
>>> I was wondering if it is possible to reject Producer message if no Consumer
>>> is available.
>>> I did search the forum, googled very much, but found nothing close to my
>>> scenario.
>>>
>>> My implementation is about a RPC mechanism. So if the requestor (Producer)
>>> does not have a response (from Consumer) it will hang until a timeout
>>> happen.
>>> I would like to remove the timeout and give a (semi) immediate exception to
>>> the Producer.
>>>
>>> Is it possible through a Broker Filter?  Or by any other means?
>>>
>>> Please, tell me if I missed something useful from my explanation, I'll be
>>> glad to add further information.
>>>
>>> I'm using ActiveMq 5.8
>>> Non persistent queue
>>> I'm using it with Debian Linux and Ms Windows
>>> Jdk 1.7_21
>>> In embedded mode.
>>>
>>> best regards
>>> Simone Giacomelli
>>>
>>> PS I was successfully able to create a customized authentication plugin.
>>> And another plugin to reject Consumer if Destination have already one
>>> Consumer
>>> I love ActiveMQ :)
>>>
>>
>>
>>
>> --
>> *Christian Posta*
>> http://www.christianposta.com/blog
>> twitter: @christianposta
>

Re: Reject queue message if no Consumer is available

Posted by Johan Edstrom <se...@gmail.com>.
Like Christian stated it doesn't make a whole lot of sense.
You don't need a plugin to reject either, use exclusive consumers.

On Oct 8, 2013, at 1:28 PM, Christian Posta <ch...@gmail.com> wrote:

> Well, the whole point of queueing messages is to be able to asynchronously
> deliver messages so that consumers don't have to be aware of producers and
> vice versa. That is, if there are no consumers, the producers should still
> be able to work. Maybe you can describe the problem you're trying to solve
> a little better?
> 
> 
> On Tue, Oct 8, 2013 at 10:35 AM, Simone Giacomelli <in...@simone.pro> wrote:
> 
>> I'm using ActiveMq in a request/response configuration.
>> 
>> I was wondering if it is possible to reject Producer message if no Consumer
>> is available.
>> I did search the forum, googled very much, but found nothing close to my
>> scenario.
>> 
>> My implementation is about a RPC mechanism. So if the requestor (Producer)
>> does not have a response (from Consumer) it will hang until a timeout
>> happen.
>> I would like to remove the timeout and give a (semi) immediate exception to
>> the Producer.
>> 
>> Is it possible through a Broker Filter?  Or by any other means?
>> 
>> Please, tell me if I missed something useful from my explanation, I'll be
>> glad to add further information.
>> 
>> I'm using ActiveMq 5.8
>> Non persistent queue
>> I'm using it with Debian Linux and Ms Windows
>> Jdk 1.7_21
>> In embedded mode.
>> 
>> best regards
>> Simone Giacomelli
>> 
>> PS I was successfully able to create a customized authentication plugin.
>> And another plugin to reject Consumer if Destination have already one
>> Consumer
>> I love ActiveMQ :)
>> 
> 
> 
> 
> -- 
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta


Re: Reject queue message if no Consumer is available

Posted by Christian Posta <ch...@gmail.com>.
Well, the whole point of queueing messages is to be able to asynchronously
deliver messages so that consumers don't have to be aware of producers and
vice versa. That is, if there are no consumers, the producers should still
be able to work. Maybe you can describe the problem you're trying to solve
a little better?


On Tue, Oct 8, 2013 at 10:35 AM, Simone Giacomelli <in...@simone.pro> wrote:

> I'm using ActiveMq in a request/response configuration.
>
> I was wondering if it is possible to reject Producer message if no Consumer
> is available.
> I did search the forum, googled very much, but found nothing close to my
> scenario.
>
> My implementation is about a RPC mechanism. So if the requestor (Producer)
> does not have a response (from Consumer) it will hang until a timeout
> happen.
> I would like to remove the timeout and give a (semi) immediate exception to
> the Producer.
>
> Is it possible through a Broker Filter?  Or by any other means?
>
> Please, tell me if I missed something useful from my explanation, I'll be
> glad to add further information.
>
> I'm using ActiveMq 5.8
> Non persistent queue
> I'm using it with Debian Linux and Ms Windows
> Jdk 1.7_21
> In embedded mode.
>
> best regards
> Simone Giacomelli
>
> PS I was successfully able to create a customized authentication plugin.
> And another plugin to reject Consumer if Destination have already one
> Consumer
> I love ActiveMQ :)
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta