You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Magnus Heino <ma...@filur.org> on 2008/02/15 12:08:19 UTC
ProducerTemplate and JMSReplyTo
Seems like a easy thing to me, but I can't get it working.
I have this:
@EndpointInject(uri = "jms:queue:updateRequest")
private ProducerTemplate<Exchange> producer;
and want to send a message, and set JMSReplyTo.
How do I do it?
this.producer.sendBodyAndHeader("mybody, "JMSReplyTo",
"jms:queue:updateReceipt");
That doesn't work...
What I really want to do is listen to a jms queue, unmarshal the result with
jaxb, forward that to a spring bean, and return the result from the spring
bean to the jsmreplyto in the received message. Seems like a basic simple
thing, but how? :)
Thanks,
--
/Magnus Heino
Re: ProducerTemplate and JMSReplyTo
Posted by Magnus Heino <ma...@filur.org>.
On Fri, Feb 15, 2008 at 12:53 PM, James Strachan <ja...@gmail.com>
wrote:
> On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> > On Fri, Feb 15, 2008 at 12:28 PM, James Strachan <
> james.strachan@gmail.com>
> > wrote:
> >
> >
> > > On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> > > > Seems like a easy thing to me, but I can't get it working.
> > > >
> > > > I have this:
> > > >
> > > > @EndpointInject(uri = "jms:queue:updateRequest")
> > > > private ProducerTemplate<Exchange> producer;
> > > >
> > > > and want to send a message, and set JMSReplyTo.
> > > >
> > > > How do I do it?
> > > >
> > > > this.producer.sendBodyAndHeader("mybody, "JMSReplyTo",
> > > > "jms:queue:updateReceipt");
> > > >
> > > > That doesn't work...
> > >
> > > The easiest way is to just set the pattern on the exchange to InOut
> > >
> > > exchange.setPattern(ExchangePattern.InOut)
> > >
> > > and it'll use a temporary queue to do request reply.
> > >
> >
> >
> > How do I do this using the producer above? Where do I get hold of this
> > exchange? Please be explicit, I just don't get this :-P
>
> Oh sorry - I forgot you were using the send* method and not having
> access to the underlying Exchange.
>
> Firstly you can pass a Processor to most of the send* methods to get
> the Exchange before its sent if you wanna noodle/transform it.
Ok, but the setPattern method is on DefaultExchange, not Exchange. Is it
safe to always cast this then or what?
>
> But the method I should have directed you to is...
>
>
> producer.requestBodyAndHeader(...)
>
> which does the same thing under the covers (i.e. uses an InOut
> exchange rather than InOnly)
But that just if I want to set JMSReplyTo myself, and not use a temporary
queue?
/Magnus
>
>
>
>
> > > Though if you wanna set the JMSReplyTo queue, you need to currently
> > > set the actual JMS Destination as the header value.
> > >
> > > I guess we could get smart - and have some kinda converter method so
> > > that if its a String we convert it to the queue name?
> > >
> > > So we could do something like...
> > > producer.sendBodyAndHeader("mybody, "JMSReplyTo",
> "queue:updateReceipt");
> > >
> > >
> > > > What I really want to do is listen to a jms queue, unmarshal the
> result
> > > with
> > > > jaxb, forward that to a spring bean, and return the result from
> the
> > > spring
> > > > bean to the jsmreplyto in the received message. Seems like a basic
> > > simple
> > > > thing, but how? :)
> > >
> > > Oh thats even easier :)
> > >
> > >
> > > from("jms:myQueue").bean("myBeanName", "theMethod");
> > >
> > > Make sure you've camel-jaxb and camel-jms on the classpath and it
> > > should just work.
> >
> >
> >
> > Ok, thats actually how I'm doing it. But right now the response is sent
> > nowhere, but then I just need to set this exchange pattern then I
> guess..
> > somehow..
>
> Is there a JMSReplyTo header on the message when you get it on the server
> side?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
--
/Magnus Heino
Re: ProducerTemplate and JMSReplyTo
Posted by James Strachan <ja...@gmail.com>.
On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> On Fri, Feb 15, 2008 at 12:28 PM, James Strachan <ja...@gmail.com>
> wrote:
>
>
> > On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> > > Seems like a easy thing to me, but I can't get it working.
> > >
> > > I have this:
> > >
> > > @EndpointInject(uri = "jms:queue:updateRequest")
> > > private ProducerTemplate<Exchange> producer;
> > >
> > > and want to send a message, and set JMSReplyTo.
> > >
> > > How do I do it?
> > >
> > > this.producer.sendBodyAndHeader("mybody, "JMSReplyTo",
> > > "jms:queue:updateReceipt");
> > >
> > > That doesn't work...
> >
> > The easiest way is to just set the pattern on the exchange to InOut
> >
> > exchange.setPattern(ExchangePattern.InOut)
> >
> > and it'll use a temporary queue to do request reply.
> >
>
>
> How do I do this using the producer above? Where do I get hold of this
> exchange? Please be explicit, I just don't get this :-P
Oh sorry - I forgot you were using the send* method and not having
access to the underlying Exchange.
Firstly you can pass a Processor to most of the send* methods to get
the Exchange before its sent if you wanna noodle/transform it.
But the method I should have directed you to is...
producer.requestBodyAndHeader(...)
which does the same thing under the covers (i.e. uses an InOut
exchange rather than InOnly)
> > Though if you wanna set the JMSReplyTo queue, you need to currently
> > set the actual JMS Destination as the header value.
> >
> > I guess we could get smart - and have some kinda converter method so
> > that if its a String we convert it to the queue name?
> >
> > So we could do something like...
> > producer.sendBodyAndHeader("mybody, "JMSReplyTo", "queue:updateReceipt");
> >
> >
> > > What I really want to do is listen to a jms queue, unmarshal the result
> > with
> > > jaxb, forward that to a spring bean, and return the result from the
> > spring
> > > bean to the jsmreplyto in the received message. Seems like a basic
> > simple
> > > thing, but how? :)
> >
> > Oh thats even easier :)
> >
> >
> > from("jms:myQueue").bean("myBeanName", "theMethod");
> >
> > Make sure you've camel-jaxb and camel-jms on the classpath and it
> > should just work.
>
>
>
> Ok, thats actually how I'm doing it. But right now the response is sent
> nowhere, but then I just need to set this exchange pattern then I guess..
> somehow..
Is there a JMSReplyTo header on the message when you get it on the server side?
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: ProducerTemplate and JMSReplyTo
Posted by Magnus Heino <ma...@filur.org>.
On Fri, Feb 15, 2008 at 12:28 PM, James Strachan <ja...@gmail.com>
wrote:
> On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> > Seems like a easy thing to me, but I can't get it working.
> >
> > I have this:
> >
> > @EndpointInject(uri = "jms:queue:updateRequest")
> > private ProducerTemplate<Exchange> producer;
> >
> > and want to send a message, and set JMSReplyTo.
> >
> > How do I do it?
> >
> > this.producer.sendBodyAndHeader("mybody, "JMSReplyTo",
> > "jms:queue:updateReceipt");
> >
> > That doesn't work...
>
> The easiest way is to just set the pattern on the exchange to InOut
>
> exchange.setPattern(ExchangePattern.InOut)
>
> and it'll use a temporary queue to do request reply.
>
How do I do this using the producer above? Where do I get hold of this
exchange? Please be explicit, I just don't get this :-P
>
> Though if you wanna set the JMSReplyTo queue, you need to currently
> set the actual JMS Destination as the header value.
>
> I guess we could get smart - and have some kinda converter method so
> that if its a String we convert it to the queue name?
>
> So we could do something like...
> producer.sendBodyAndHeader("mybody, "JMSReplyTo", "queue:updateReceipt");
>
>
> > What I really want to do is listen to a jms queue, unmarshal the result
> with
> > jaxb, forward that to a spring bean, and return the result from the
> spring
> > bean to the jsmreplyto in the received message. Seems like a basic
> simple
> > thing, but how? :)
>
> Oh thats even easier :)
>
>
> from("jms:myQueue").bean("myBeanName", "theMethod");
>
> Make sure you've camel-jaxb and camel-jms on the classpath and it
> should just work.
Ok, thats actually how I'm doing it. But right now the response is sent
nowhere, but then I just need to set this exchange pattern then I guess..
somehow..
Thanks,
/Magnus
Re: ProducerTemplate and JMSReplyTo
Posted by James Strachan <ja...@gmail.com>.
On 15/02/2008, Magnus Heino <ma...@filur.org> wrote:
> Seems like a easy thing to me, but I can't get it working.
>
> I have this:
>
> @EndpointInject(uri = "jms:queue:updateRequest")
> private ProducerTemplate<Exchange> producer;
>
> and want to send a message, and set JMSReplyTo.
>
> How do I do it?
>
> this.producer.sendBodyAndHeader("mybody, "JMSReplyTo",
> "jms:queue:updateReceipt");
>
> That doesn't work...
The easiest way is to just set the pattern on the exchange to InOut
exchange.setPattern(ExchangePattern.InOut)
and it'll use a temporary queue to do request reply.
Though if you wanna set the JMSReplyTo queue, you need to currently
set the actual JMS Destination as the header value.
I guess we could get smart - and have some kinda converter method so
that if its a String we convert it to the queue name?
So we could do something like...
producer.sendBodyAndHeader("mybody, "JMSReplyTo", "queue:updateReceipt");
> What I really want to do is listen to a jms queue, unmarshal the result with
> jaxb, forward that to a spring bean, and return the result from the spring
> bean to the jsmreplyto in the received message. Seems like a basic simple
> thing, but how? :)
Oh thats even easier :)
from("jms:myQueue").bean("myBeanName", "theMethod");
Make sure you've camel-jaxb and camel-jms on the classpath and it
should just work.
If you wanna tinker with the JAXB context you could use an explicit
unmarshal in between...
http://activemq.apache.org/camel/jaxb.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com