right way to send and receive messages in a BrokerPlugin

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

right way to send and receive messages in a BrokerPlugin

MatsH
Hey,

I'm writing a special broker plugin that makes it so that a client can
only have a single login (per username) to a network of brokers at any
one time. To do this I am making the plugin send a message to all the
other instances of the plugin on the network of brokers (using a topic)
and if they have the user logged in they kick them off.

To do this though I need the plugin to subscribe as a producer and
consumer on my special topic, and I'm having some trouble. Is there a
right way to do this?

I've seen how the AdvisoryBroker and BrokerSupport send messages, is
that the way to do it? I can't seem to find any code that actually works
like a consumer though and receives messages on the ActiveMQ.Advisory
topics, I assume they exist? Basically, what is the right way for a
BrokerPlugin to send and receive messages in their implementation
methods?

Currently I am actually calling BrokerFilter.getVmConnectorUri() when my
plugin is instantiated, appending "?waitForStart=60000&create=false" to
the URI and then creating a new ActiveMQConnectionFactory from that, and
then creating a consumer and a producer sessions and threads. However
I'm having some trouble with the new VM broker it starts, so I was
hoping there might be a better way.

--
Mats Henrikson
Software Engineer
SunGard Kiodex

Think before you print


Reply | Threaded
Open this post in threaded view
|

RE: right way to send and receive messages in a BrokerPlugin

MatsH
> However
> I'm having some trouble with the new VM broker it starts, so I was
> hoping there might be a better way.

For reference my problems were that the messages to my topic were not
being distributed to the other brokers in the network. I've just figured
out that this is because I put my topic inside the ActiveMQ.Advisory
space, and messages to that space seem to be kept local. Once I put my
topic outside of that space the messages are distributed to the other
brokers in the network.

However I am still interested in knowing if there is a right way to do
things as per my last email in this thread.

Regards,

Mats Henrikson

Reply | Threaded
Open this post in threaded view
|

Re: right way to send and receive messages in a BrokerPlugin

rajdavies

On 3 Aug 2009, at 20:24, <[hidden email]> <[hidden email]
 > wrote:

>> However
>> I'm having some trouble with the new VM broker it starts, so I was
>> hoping there might be a better way.
>
> For reference my problems were that the messages to my topic were not
> being distributed to the other brokers in the network. I've just  
> figured
> out that this is because I put my topic inside the ActiveMQ.Advisory
> space, and messages to that space seem to be kept local. Once I put my
> topic outside of that space the messages are distributed to the other
> brokers in the network.
>
> However I am still interested in knowing if there is a right way to do
> things as per my last email in this thread.
>
> Regards,
>
> Mats Henrikson
>


Hi Mats,

the way you described setting up the internal consumers/producers  
using JMS constructs and vm:// transport is the correct way to  
implement what you are trying to do

cheers,

Rob

Rob Davies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/




Reply | Threaded
Open this post in threaded view
|

Re: right way to send and receive messages in a BrokerPlugin

Jose Luna-2
Mats,

Since Rob has noted that this as the correct way, would you consider adding your plugin to the wiki when it is complete?   I think others would find it useful/interesting, including myself.

JLuna



----- Original Message ----

> From: Rob Davies <[hidden email]>
> To: [hidden email]
> Sent: Monday, August 3, 2009 5:12:24 PM
> Subject: Re: right way to send and receive messages in a BrokerPlugin
>
>
> On 3 Aug 2009, at 20:24,
> wrote:
>
> >> However
> >> I'm having some trouble with the new VM broker it starts, so I was
> >> hoping there might be a better way.
> >
> > For reference my problems were that the messages to my topic were not
> > being distributed to the other brokers in the network. I've just figured
> > out that this is because I put my topic inside the ActiveMQ.Advisory
> > space, and messages to that space seem to be kept local. Once I put my
> > topic outside of that space the messages are distributed to the other
> > brokers in the network.
> >
> > However I am still interested in knowing if there is a right way to do
> > things as per my last email in this thread.
> >
> > Regards,
> >
> > Mats Henrikson
> >
>
>
> Hi Mats,
>
> the way you described setting up the internal consumers/producers using JMS
> constructs and vm:// transport is the correct way to implement what you are
> trying to do
>
> cheers,
>
> Rob
>
> Rob Davies
> I work here: http://fusesource.com
> My Blog: http://rajdavies.blogspot.com/
> I'm writing this: http://www.manning.com/snyder/



     
Reply | Threaded
Open this post in threaded view
|

RE: right way to send and receive messages in a BrokerPlugin

MatsH
Hi JLuna,

> Since Rob has noted that this as the correct way, would you consider
> adding your plugin to the wiki when it is complete?   I think others
would
> find it useful/interesting, including myself.

Well, I can't add specifically what I have since unfortunately I've gone
down the path of writing one monolithic plugin that does the job of what
3 or 4 plugins should do really.

However, I will keep in mind that there is interest, and I should be
able to at least add a description of how it works, and as long as there
isn't any internal resistance I might be able to split out that part
into it's own plugin and put that up.

Regards,

Mats Henrikson