activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <>
Subject Re: peer protocol - wait for discovery
Date Mon, 07 Nov 2011 09:49:16 GMT
Hi Stefan,

the problem is that you send non-persistent messages to the topic and if
there's no consumers on the topic (which there isn't in your case), the
message is being discarded. As you suggested, the solution would be to use
advisory messages to wait for a consumer on your topic, before sending a

You can do that by simply registering a consumer for

Destination advisoryTopic = AdvisorySupport.getConsumerAdvisoryTopic(dest)

and send a message only after you received a first message there.

Dejan Bosanac -
The experts in open source integration and messaging -
ActiveMQ in Action -
Blog -

On Fri, Nov 4, 2011 at 4:37 PM, Stefan Oestreicher <> wrote:

> Hi,
> I'm working on a multi-user Swing application where it would be nice if
> users could be informed about updates made by others in real-time. For this
> application it is pretty much a convenience feature so it's not necessary
> for correct operation.
> After looking into ActiveMQ I discovered the Peer protocol which seems to
> be exactly what I need because I don't want to use a central server. I made
> a small test example which seemed to work perfectly.
> But one thing I would like to do is send a message on application start to
> announce the client to the others.  Unfortunately I'm not sure how to get
> this to work because if I immediately send a message after starting the
> connection it's only delivered to the embedded broker. Calling Thread.sleep
> for a short time before sending the message makes it work. So I guess
> that's because it takes some time until the discovery is finished, but how
> can I wait for that? I stumbled upon Advisories and it sounds like maybe
> that's what I need but I'm having a hard time finding more information
> about this. I'm quite new to JMS so please forgive my ignorance.
> I would appreciate any pointers.
> You can see the relevant part of the test code I used here, in case it
> makes any difference:
> thanks,
> Stefan

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message