You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by mandjeo <ma...@gmail.com> on 2012/07/23 11:51:08 UTC

Sending message from broker to clients

Hi guys,

I am implementing system based on ActiveMQ and I want to send messages from
broker to the connected applications, that is, I want a broker to be a
producer of the messages and put them in appropriate queues.

I am trying to do it in similar way as it is implemented in for example
StatisticsBroker, but from time to time I am having this duplicate
dispatches, that is, for example my acknowledge method is called twice for a
certain message...

Can you tell me what would be the proper way to send messages from the
broker to the queues inside it (send the messages to the connected
applications) and if you have idea why this duplicate dispatch is
happening...?

Thanks !!!





--
View this message in context: http://activemq.2283324.n4.nabble.com/Sending-message-from-broker-to-clients-tp4654236.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Sending message from broker to clients

Posted by Dejan Bosanac <de...@nighttale.net>.
You need to have ConnectionContext to send messages within the broker.
If you don't have any you can try grabbing admin connection context
Broker.getAdminConnectionContext(). It seems like your case is an
extension of current advisory support in the broker. If so you might
consider extending it to your needs.


Regards
-- 
Dejan Bosanac
Senior Software Engineer | FuseSource Corp.
dejanb@fusesource.com | fusesource.com
skype: dejan.bosanac | twitter: @dejanb
blog: http://www.nighttale.net
ActiveMQ in Action: http://www.manning.com/snyder/


On Mon, Jul 23, 2012 at 6:13 PM, mandjeo <ma...@gmail.com> wrote:
> Thanks for the reply ! (Hvala puno! :))
>
> My use case is that I need to send messages as a reaction to some events in
> the broker.
> So lets say that when some conditions are fulfilled I need to send a new
> message to some queue.
> In the example that you've sent it is the scheduleRedelivery method that is
> doing more or less what I need,
> but here you got connectionContext object from the sendToDeadLetterQueue
> method, and you are using broker defined in it to send the message.
> What if I don't have a ConnectionContext object, that is I want to send
> message from some other methods where I don't have a reference to it.
> How can I create one and reference to which Broker should I set in it?
>
> Regards !
>
> Milos Andjelkovic
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Sending-message-from-broker-to-clients-tp4654236p4654263.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Sending message from broker to clients

Posted by mandjeo <ma...@gmail.com>.
Thanks for the reply ! (Hvala puno! :))

My use case is that I need to send messages as a reaction to some events in
the broker. 
So lets say that when some conditions are fulfilled I need to send a new
message to some queue.
In the example that you've sent it is the scheduleRedelivery method that is
doing more or less what I need, 
but here you got connectionContext object from the sendToDeadLetterQueue
method, and you are using broker defined in it to send the message. 
What if I don't have a ConnectionContext object, that is I want to send
message from some other methods where I don't have a reference to it. 
How can I create one and reference to which Broker should I set in it?

Regards !

Milos Andjelkovic




--
View this message in context: http://activemq.2283324.n4.nabble.com/Sending-message-from-broker-to-clients-tp4654236p4654263.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Sending message from broker to clients

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

do you need to do it from the broker, or just the same JVM. If it
doesn't need to be done from the broker, you can use regular JMS
producer to connect to your broker and send messages (or even use
Camel to make things easier).

If it needs to be from the broker, you probably need to create a
plugin (http://activemq.apache.org/developing-plugins.html) that will
do something on certain event. One of the examples of plugins that
sends messages can be found here

https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java?hb=true

In any case, it'd be good to hear more about your use case to find the
best approach.

Regards
-- 
Dejan Bosanac
Senior Software Engineer | FuseSource Corp.
dejanb@fusesource.com | fusesource.com
skype: dejan.bosanac | twitter: @dejanb
blog: http://www.nighttale.net
ActiveMQ in Action: http://www.manning.com/snyder/


On Mon, Jul 23, 2012 at 4:57 PM, mandjeo <ma...@gmail.com> wrote:
> Is it possible that nobody had need to send message from the broker to some
> queue...
>
> My problem is that I cannot find how should I create ProducerBrokerExchange
> and ConnectionContext objects appropriately.
>
> Please if anybody has any ideas...
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Sending-message-from-broker-to-clients-tp4654236p4654260.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Sending message from broker to clients

Posted by mandjeo <ma...@gmail.com>.
Is it possible that nobody had need to send message from the broker to some
queue...

My problem is that I cannot find how should I create ProducerBrokerExchange
and ConnectionContext objects appropriately. 

Please if anybody has any ideas...



--
View this message in context: http://activemq.2283324.n4.nabble.com/Sending-message-from-broker-to-clients-tp4654236p4654260.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.