Naive Question (?) Why are headers not maintained when message is forwarded?

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

Naive Question (?) Why are headers not maintained when message is forwarded?

DominicTulley
I'm new to Camel so please forgive me if this is a naive question, but it looks to me like my jms message headers are not being maintained when the message is forwarded from one queue to another.
In particular, I'm trying to use the JSMReplyTo mechanism (with a temporary queue) but the header vanishes as the message passes through Camel.

I've got Camel running inside ActiveMQ 4.1.1 with some hard coded destinations:
    <destinations>
      <queue physicalName="RegQueue" />
      <queue physicalName="Out1Queue" />
    </destinations>

and a simple routing rule:

  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring" packages="org.foo.bar">
    <route>
      <from uri="activemq:RegQueue"/>
      <to uri="activemq:Out1Queue"/>
    </route>   
  </camelContext> 

Any help would be appreciated.

Thanks,

-Dominic
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

jstrachan
On 8/10/07, DominicTulley <[hidden email]> wrote:

>
> I'm new to Camel so please forgive me if this is a naive question, but it
> looks to me like my jms message headers are not being maintained when the
> message is forwarded from one queue to another.
> In particular, I'm trying to use the JSMReplyTo mechanism (with a temporary
> queue) but the header vanishes as the message passes through Camel.
>
> I've got Camel running inside ActiveMQ 4.1.1 with some hard coded
> destinations:
>     <destinations>
>       <queue physicalName="RegQueue" />
>       <queue physicalName="Out1Queue" />
>     </destinations>
>
> and a simple routing rule:
>
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring"
> packages="org.foo.bar">
>     <route>
>       <from uri="activemq:RegQueue"/>
>       <to uri="activemq:Out1Queue"/>
>     </route>
>   </camelContext>
>
> Any help would be appreciated.

Great catch Dominic!

It turns out we were copying across all the JMS properties; but not
copying the 3 custom JMS properties "JMSCorrelationID", "JMSReplyTo"
and "JMSType". We also were not exposing the other JMS* properties to
consumers of the message either (other than via the actual JMS message
on the JmsExchange/JmsMessage classes).

I raised a JIRA to track this issue...
https://issues.apache.org/activemq/browse/CAMEL-96

I've just patched trunk to fix this; there's a test case in which I
managed to reproduce your issue here...
https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-activemq/src/test/java/org/apache/camel/component/activemq/ActiveMQJmsHeaderRouteTest.java

which shows this is now working. Thanks for spotting this!

--
James
-------
http://macstrac.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

DominicTulley
Thanks James, I've pulled the latest source out of svn and built it, but I'm having trouble making it run in ActiveMQ (it complains about NoClassDefFound for javax.xml.bind.JAXBException).  
Are there instructions anywhere for getting 1.1 to build and deploy?  I presume I'm just missing one or more libraries.  I've put all the ones from apache-camel-1.1.SNAPSHOT.zip (the result of my build I think!) into the ActiveMQ lib and optional folders as appropriate and also placed the main apache-camel-1.1-SNAPSHOT.jar file.  Are there others I need that aren't being pulled in by maven just now?

Thanks,

-Dominic
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

jstrachan
On 8/10/07, DominicTulley <[hidden email]> wrote:
> Thanks James, I've pulled the latest source out of svn and built it, but I'm
> having trouble making it run in ActiveMQ (it complains about NoClassDefFound
> for javax.xml.bind.JAXBException).

Do you have a stack trace? FWIW Camel now uses JAXB annotations in the
camel-core but they should not be required unless you are using XML to
parse the routing rules.

Ah - are you using this in the ActiveMQ broker? If so we might need to
swizzle the pom to ensure jaxb2 is included in the binary distro...


> Are there instructions anywhere for getting 1.1 to build and deploy?  I
> presume I'm just missing one or more libraries.  I've put all the ones from
> apache-camel-1.1.SNAPSHOT.zip (the result of my build I think!) into the
> ActiveMQ lib and optional folders as appropriate and also placed the main
> apache-camel-1.1-SNAPSHOT.jar file.  Are there others I need that aren't
> being pulled in by maven just now?

The build of the ActiveMQ broker should work and do the right thing -
but in this case, am thinking JAXB API and impl jars might be missing.
Sorry about that! Am off to check the ActiveMQ build is up to date...

--
James
-------
http://macstrac.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

DominicTulley
Hi, yes I'm trying to run it within ActiveMQ and there's no jaxb jars in the lib or optional directories.

The first part of the stack trace is below.
I dropped in jaxb-api-2.0 and jaxb-impl-2.0.3 which maven had lying around.  Now it complains about javax.activation.DataSource being missing (NoClassDefFoundError).  Stack trace after the jaxb one...

I dropped in activation-1.1.jar from Maven and then javax.xml.stream.XMLStreamException not found.

I dropped in all the javax.xml jars Maven knew about (jsr173_api-1.0 saaj-api-1.3 and jaxws-api-2.0).

It then started up happily (haven't tested it if sends any messages yet!).

Perhaps there are a few broken dependencies?!

Thanks,

-Dominic
================================

WARN  XBeanNamespaceHandlerResolver  - Ignoring namespace handler [org.apache.ca
mel.spring.handler.CamelNamespaceHandler]: problem with handler class file or de
pendent class
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
        at java.lang.Class.getConstructor0(Class.java:2671)
        at java.lang.Class.getDeclaredConstructor(Class.java:1953)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:6
0)
        at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver
.initHandlerMappings(DefaultNamespaceHandlerResolver.java:122)
        at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver
.<init>(DefaultNamespaceHandlerResolver.java:96)
        at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver
.<init>(DefaultNamespaceHandlerResolver.java:82)
        at org.apache.xbean.spring.context.v2.XBeanNamespaceHandlerResolver.<ini
t>(XBeanNamespaceHandlerResolver.java:26)
        at org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.creat
eDefaultNamespaceHandlerResolver(XBeanXmlBeanDefinitionReader.java:87)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.createR
eaderContext(XmlBeanDefinitionReader.java:477)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registe
rBeanDefinitions(XmlBeanDefinitionReader.java:458)
        at org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.regis
terBeanDefinitions(XBeanXmlBeanDefinitionReader.java:79)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB

================================

Loading message broker from: xbean:activemq.xml
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: org.spr
ingframework.beans.factory.BeanDefinitionStoreException: Unexpected exception pa
rsing XML document from class path resource [activemq.xml]; nested exception is
java.lang.NoClassDefFoundError: javax/activation/DataSource
java.lang.RuntimeException: Failed to execute start task. Reason: org.springfram
ework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing X
ML document from class path resource [activemq.xml]; nested exception is java.la
ng.NoClassDefFoundError: javax/activation/DataSource
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:70)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:50)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:65)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:50)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:202)
        at org.apache.activemq.console.Main.main(Main.java:91)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexp
ected exception parsing XML document from class path resource [activemq.xml]; ne
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

DominicTulley
It ran OK for me, but did complain about other classes (so javax.mail is missing at least, perhaps more)...

However, I got a message to go through and still had the ReplyTo value intact :-)

Thanks,

-Dominic
Reply | Threaded
Open this post in threaded view
|

Re: Naive Question (?) Why are headers not maintained when message is forwarded?

jstrachan
On 8/10/07, DominicTulley <[hidden email]> wrote:
>
> It ran OK for me, but did complain about other classes (so javax.mail is
> missing at least, perhaps more)...
>
> However, I got a message to go through and still had the ReplyTo value
> intact :-)

Great! :) Thanks for letting us know!

I've been tinkering with the ActiveMQ build and I think its sorted
now; if you build the assembly from trunk, it should run fine now
(fingers crossed). I just tried it and it worked fine for me.
(Tomorrows nightly snapshot should be fixed too).

Basically it needs the JAXB2 API and implementation, which the
implementation also requires the StAX API and an impl (such as
woodstox or whatever).
--
James
-------
http://macstrac.blogspot.com/