Hi Ryan I guess you can just modify the IN body if you want to keep the original JmsExchange. But yeah maybe it shoud keep a reference to the orginal JMSMessage when it creates a new JmsExchange. I think there is a method newInstance() that is responsible for that.
Feel free to create a ticket in JIRA. On Wed, Jan 21, 2009 at 5:03 PM, Ryan Stewart <[email protected]> wrote: > > When you get a JMS message initially, like: > from("activemq:SomeQueue").to("someProcessor"); > > the processor, "someProcessor" in this case, is invoked with a JmsExchange > that has an in message and no out message (i.e. out = null). The in message > is a JmsMessage, and that has the original JMS Message set in its jmsMessage > property. So far so good. When the processor attempts to use the out of the > JmsExchange something odd happens. Since out doesn't exist, it will be > lazily created, but when this happens, the original JMS Message isn't > transferred to the newly created JmsMessage object. The only way that the > out would get the Message is if you manually set it or some representation > of it in the body of the out JmsMessage. > > I'm not sure whether this is a bug, but it seems odd behavior at least. I > observed the behavior in Camel 1.4, and the code doesn't seem to have > changed in 1.5. The relevant code is below. > > JmsExchange.getOut(true): > public JmsMessage getOut(boolean lazyCreate) { > return (JmsMessage) super.getOut(lazyCreate); > } > > delegates to DefaultExchange for lazy creation: > public Message getOut(boolean lazyCreate) { > if (out == null && lazyCreate) { > out = createOutMessage(); > configureMessage(out); > } > return out; > } > > which delegates back to JmsExchange for the create: > protected JmsMessage createOutMessage() { > return new JmsMessage(); > } > > and then runs its own (DefaultMessage's) configure: > protected void configureMessage(Message message) { > if (message instanceof MessageSupport) { > MessageSupport messageSupport = (MessageSupport)message; > messageSupport.setExchange(this); > } > } > > It seems that JmsExchange should have a line added to its getOut(boolean) > method like so: > public JmsMessage getOut(boolean lazyCreate) { > JmsMessage result = (JmsMessage) super.getOut(lazyCreate); > result.setJmsMessage(((JmsMessage) getIn()).getJmsMessage()); > return result; > } > > -- > View this message in context: > http://www.nabble.com/JmsExchange.getOut%28%29-loses-the-original-JMS-Message-tp21586153s22882p21586153.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
