You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hennejg <j....@levigo.de> on 2008/10/29 11:36:49 UTC
Howto for MessageListenerProcessor
Hi,
in this message
http://www.nabble.com/How-camel-resolve-JNDI-End-point-td13039322s22882.html#a13100603
the MessageListenerProcessor is mentioned as a possible way to feed messages
received by an MDB into camel. However, I found it rather non-obvious how
this is actually accomplished. Is there a brief howto or example of what to
provide to the MLP constructor based on a given camel context?
Thanks!
Joerg
--
View this message in context: http://www.nabble.com/Howto-for-MessageListenerProcessor-tp20224390s22882p20224390.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto for MessageListenerProcessor
Posted by James Strachan <ja...@gmail.com>.
2008/10/29 hennejg <j....@levigo.de>:
>
> Hi,
>
> in this message
> http://www.nabble.com/How-camel-resolve-JNDI-End-point-td13039322s22882.html#a13100603
> the MessageListenerProcessor is mentioned as a possible way to feed messages
> received by an MDB into camel. However, I found it rather non-obvious how
> this is actually accomplished. Is there a brief howto or example of what to
> provide to the MLP constructor based on a given camel context?
We could do with a tutorial that shows how to invoke Camel from an MDB
- if you wanted to reuse an MDB application but just add some Camel
routing.
I've raised a JIRA to track this
https://issues.apache.org/activemq/browse/CAMEL-1033
Using trunk you can now create a JMS message listener as follows...
MessageListener listener =
CamelMessageListener.newInstance(camelContext, "direct:foo");
where "direct:foo" is whatever Camel URI you want to use to process
the incoming JMS message.
So you could wrap this up in a trivial MDB if you like to delegate
processing of the JMS message to some Camel rule.
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: Error Handling & CXF Integration
Posted by Willem Jiang <wi...@gmail.com>.
Hi ,
You should get a exception from the cxf:ws endpoint in Camel 1.5. Then
you can use Camel's ErrorHandler[1] to retry or send it to a dead letter
queue.
If you are using Camel 1.4, you will not get this kind of exception, the
camel cxf endpoint just put the exception into the exchange.
[1]http://activemq.apache.org/camel/error-handler.html
Willem
Coder One wrote:
> Say I have a route from("jms:in").to("cxf:ws") and that ws link is down, what's camel behavior? Configurable? What's the recommended practice to work with error handling or route failure/unavailability?
>
> Thanks,
>
>
>
>
>
>
>
Error Handling & CXF Integration
Posted by Coder One <co...@yahoo.com>.
Say I have a route from("jms:in").to("cxf:ws") and that ws link is down, what's camel behavior? Configurable? What's the recommended practice to work with error handling or route failure/unavailability?
Thanks,
Re: Howto for MessageListenerProcessor
Posted by hennejg <j....@levigo.de>.
James.Strachan wrote:
>
> See the helper class I just created.
>
> The other option is just create a JmsExchange object from the JMS
> Message and send that with the ProducerTemplate
>
>
That's exactly what I was looking for - brilliant! Thanks a lot.
Joerg
--
View this message in context: http://www.nabble.com/Howto-for-MessageListenerProcessor-tp20224390s22882p20229351.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Howto for MessageListenerProcessor
Posted by James Strachan <ja...@gmail.com>.
2008/10/29 hennejg <j....@levigo.de>:
>
> Hi!
>
> thanks for your quick reply!
>
>
> Claus Ibsen wrote:
>>
>> Hi
>>
>> #1: Are you using J2EE message driven beans (EJB beans)?
>> #2: Or do you want to using Spring-based message listener (what Camel
>> uses)?
>>
>> If #1 then you can send the data from your J2EE MDB to Camel using a
>> ProducerTemplate
>> ...
>>
>
> I am using J2EE, i.e. implementing a J2EE MDB. I played around with
> ProducerTemplates but was under the impression that this is probably not the
> most elegant way. If, for example, I configure a route as
> from("direct:foo").to("stream:out"); and feed (forward) a JMS Message the
> MDB received using ProducerTemplate.sendBody("direct:foo", message), the JMS
> headers are lost and there is no automatic conversion of, say, a TextMessage
> into a String etc. as it happens with the jms:-component. I was hoping for
> the MessageListenerProcessor to do something smart with the headers, but if
> forwarding the headers separately is the recommended way to go, I'm fine
> with that.
See the helper class I just created.
The other option is just create a JmsExchange object from the JMS
Message and send that with the ProducerTemplate
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
RE: Howto for MessageListenerProcessor
Posted by hennejg <j....@levigo.de>.
Hi!
thanks for your quick reply!
Claus Ibsen wrote:
>
> Hi
>
> #1: Are you using J2EE message driven beans (EJB beans)?
> #2: Or do you want to using Spring-based message listener (what Camel
> uses)?
>
> If #1 then you can send the data from your J2EE MDB to Camel using a
> ProducerTemplate
> ...
>
I am using J2EE, i.e. implementing a J2EE MDB. I played around with
ProducerTemplates but was under the impression that this is probably not the
most elegant way. If, for example, I configure a route as
from("direct:foo").to("stream:out"); and feed (forward) a JMS Message the
MDB received using ProducerTemplate.sendBody("direct:foo", message), the JMS
headers are lost and there is no automatic conversion of, say, a TextMessage
into a String etc. as it happens with the jms:-component. I was hoping for
the MessageListenerProcessor to do something smart with the headers, but if
forwarding the headers separately is the recommended way to go, I'm fine
with that.
Joerg
--
View this message in context: http://www.nabble.com/Howto-for-MessageListenerProcessor-tp20224390s22882p20226784.html
Sent from the Camel - Users mailing list archive at Nabble.com.
RE: Howto for MessageListenerProcessor
Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi
#1: Are you using J2EE message driven beans (EJB beans)?
#2: Or do you want to using Spring-based message listener (what Camel uses)?
If #1 then you can send the data from your J2EE MDB to Camel using a ProducerTemplate
If #2 then check out some of the spring-jms examples that is in the camel distro.
Here is a snippet from one of my proof of concept with Camel in WebSphere (#2)
<!-- websphere JMS connection factory -->
<jee:jndi-lookup id="wasJMSConnectionFactory" jndi-name="jms/connectionFactory"/>
<!-- jms provider -->
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="wasJMSConnectionFactory"/>
</bean>
The above is standard Spring stuff doing jndi lookup in WebSphere and a JMS component in Camel that uses the WebSphere connection factory.
Then the rest is standard Camel where you can route with from("jms:MyQueueName").to("bean:doSomething");
For instance I have defined this endpoint id in camel context (XML)
<endpoint id="gsoQueue" uri="jms:queue:gsopenInbox"/>
And then the routing in Java DSL using the endpoint id as a reference
from("gsoQueue")
// map the input from GS to our inhouse format
.processRef("mapper")
Med venlig hilsen
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: hennejg [mailto:j.henne+nabble@levigo.de]
Sent: 29. oktober 2008 11:37
To: camel-user@activemq.apache.org
Subject: Howto for MessageListenerProcessor
Hi,
in this message
http://www.nabble.com/How-camel-resolve-JNDI-End-point-td13039322s22882.html#a13100603
the MessageListenerProcessor is mentioned as a possible way to feed messages
received by an MDB into camel. However, I found it rather non-obvious how
this is actually accomplished. Is there a brief howto or example of what to
provide to the MLP constructor based on a given camel context?
Thanks!
Joerg
--
View this message in context: http://www.nabble.com/Howto-for-MessageListenerProcessor-tp20224390s22882p20224390.html
Sent from the Camel - Users mailing list archive at Nabble.com.