You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "J. Patrick Bedell" <jp...@gmail.com> on 2006/12/07 00:04:47 UTC

steps to publish to a topic for BrokerFilter-based classes?

Hello,
   I'm working on a Broker interceptor class that extends BrokerFilter.
   After processing an incoming message, I would like to publish to a
topic that is determined from the content of the message.
   My question is: is there a quicker way to publish to a topic from a
Broker than the standard method a client uses to publish (getting
connection, TopicSession, TopicPublisher, and then using the
TopicPublisher to publish)?
   Thanks!

-- 
   J. Patrick Bedell
   jpbedell@gmail.com
   http://infoeng.sourceforge.net
   http://rothbardix.blogspot.com

Re: steps to publish to a topic for BrokerFilter-based classes?

Posted by James Strachan <ja...@gmail.com>.
Yeah - you might want to look at the Virtual Destination stuff which
does this kind of thing - forwarding a message to arbitrary
destinations based on selectors/filters - you could maybe reuse some
of that code. But it seems like you've figured it out anyway :)

On 12/7/06, J. Patrick Bedell <jp...@gmail.com> wrote:
> Hi,
>    It's really not so difficult, after all.  If you have a class that
> extends BrokerFilter, then you can use the next.send(ConnectionContext
> ctxt, Message msg) method to send a Message that has been generated.
>
>   ActiveMQTopic responseTopic =
>      new ActiveMQTopic(responseTopicString);
>   ActiveMQTextMessage responseMsg =
>      new ActiveMQTextMessage();
>   responseMsg.setText( "this is the message text" );
>   responseMsg.setDestination( responseTopic );
>   responseMsg.setMessageId( new MessageId(
> java.util.UUID.randomUUID().toString() ) );
>
>   next.send(ctxt, responseMsg); /* this sends the message! */
>
>    Thanks for all your great work on ActiveMQ!
>
>    Patrick
>
>
>
> On 12/6/06, Fritz Oconer <fo...@exist.com> wrote:
> > Hi Patrick,
> >
> > What I could suggest is to use JmsTemplate to send messages and possibly
> > Spring based configurations. See unit test SpringTest.java and
> > SpringProducer.java located in
> > "${activemq.source.home}\activemq-core\src\test\java\org\apache\activemq\spring\
> > " for reference.
> >
> > Regards,
> > Fritz
> >
> > ----- Original Message -----
> > From: "J. Patrick Bedell" <jp...@gmail.com>
> > To: <ac...@geronimo.apache.org>
> > Sent: Thursday, December 07, 2006 7:04 AM
> > Subject: steps to publish to a topic for BrokerFilter-based classes?
> >
> >
> > > Hello,
> > >   I'm working on a Broker interceptor class that extends BrokerFilter.
> > >   After processing an incoming message, I would like to publish to a
> > > topic that is determined from the content of the message.
> > >   My question is: is there a quicker way to publish to a topic from a
> > > Broker than the standard method a client uses to publish (getting
> > > connection, TopicSession, TopicPublisher, and then using the
> > > TopicPublisher to publish)?
> > >   Thanks!
> > >
>
> --
>    J. Patrick Bedell
>    jpbedell@gmail.com
>    http://infoeng.sourceforge.net
>    http://rothbardix.blogspot.com
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: steps to publish to a topic for BrokerFilter-based classes?

Posted by "J. Patrick Bedell" <jp...@gmail.com>.
Hi,
   It's really not so difficult, after all.  If you have a class that
extends BrokerFilter, then you can use the next.send(ConnectionContext
ctxt, Message msg) method to send a Message that has been generated.

  ActiveMQTopic responseTopic =
     new ActiveMQTopic(responseTopicString);
  ActiveMQTextMessage responseMsg =
     new ActiveMQTextMessage();
  responseMsg.setText( "this is the message text" );
  responseMsg.setDestination( responseTopic );
  responseMsg.setMessageId( new MessageId(
java.util.UUID.randomUUID().toString() ) );

  next.send(ctxt, responseMsg); /* this sends the message! */

   Thanks for all your great work on ActiveMQ!

   Patrick



On 12/6/06, Fritz Oconer <fo...@exist.com> wrote:
> Hi Patrick,
>
> What I could suggest is to use JmsTemplate to send messages and possibly
> Spring based configurations. See unit test SpringTest.java and
> SpringProducer.java located in
> "${activemq.source.home}\activemq-core\src\test\java\org\apache\activemq\spring\
> " for reference.
>
> Regards,
> Fritz
>
> ----- Original Message -----
> From: "J. Patrick Bedell" <jp...@gmail.com>
> To: <ac...@geronimo.apache.org>
> Sent: Thursday, December 07, 2006 7:04 AM
> Subject: steps to publish to a topic for BrokerFilter-based classes?
>
>
> > Hello,
> >   I'm working on a Broker interceptor class that extends BrokerFilter.
> >   After processing an incoming message, I would like to publish to a
> > topic that is determined from the content of the message.
> >   My question is: is there a quicker way to publish to a topic from a
> > Broker than the standard method a client uses to publish (getting
> > connection, TopicSession, TopicPublisher, and then using the
> > TopicPublisher to publish)?
> >   Thanks!
> >

-- 
   J. Patrick Bedell
   jpbedell@gmail.com
   http://infoeng.sourceforge.net
   http://rothbardix.blogspot.com

Re: steps to publish to a topic for BrokerFilter-based classes?

Posted by Fritz Oconer <fo...@exist.com>.
Hi Patrick,

What I could suggest is to use JmsTemplate to send messages and possibly 
Spring based configurations. See unit test SpringTest.java and 
SpringProducer.java located in 
"${activemq.source.home}\activemq-core\src\test\java\org\apache\activemq\spring\ 
" for reference.

Regards,
Fritz

----- Original Message ----- 
From: "J. Patrick Bedell" <jp...@gmail.com>
To: <ac...@geronimo.apache.org>
Sent: Thursday, December 07, 2006 7:04 AM
Subject: steps to publish to a topic for BrokerFilter-based classes?


> Hello,
>   I'm working on a Broker interceptor class that extends BrokerFilter.
>   After processing an incoming message, I would like to publish to a
> topic that is determined from the content of the message.
>   My question is: is there a quicker way to publish to a topic from a
> Broker than the standard method a client uses to publish (getting
> connection, TopicSession, TopicPublisher, and then using the
> TopicPublisher to publish)?
>   Thanks!
>
> -- 
>   J. Patrick Bedell
>   jpbedell@gmail.com
>   http://infoeng.sourceforge.net
>   http://rothbardix.blogspot.com