JbiMessage: removing headers/attachments won't propergate
---------------------------------------------------------
Key: SM-1884
URL: https://issues.apache.org/activemq/browse/SM-1884
Project: ServiceMix
Issue Type: Bug
Components: servicemix-camel
Affects Versions: 3.3.1
Environment: OS: Linux chriNB 2.6.24-24-generic #1 SMP Fri Jul 24
22:46:06 UTC 2009 i686 GNU/Linux
JAVA:
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
Server:
apache-tomcat-6.0.14
Reporter: Christian Connert
The problem is that if a header is added it can't be removed in the future:
Example spring configuration:
<camel:route>
<camel:from uri="someURI"/>
<camel:pipeline >
<camel:setHeader
propertyName="test"><camel:constant>test</camel:constant> </camel:setHeader>
<camel:to uri="someOtherURI"/>
<camel:removeHeader headerName="test"/>
<camel:to uri="someOtherURI"/>
</camel:pipeline>
</camel:route>
The "test" header entry won't be removed from the underlying NormalizedMessage.
Within a pipeline, as in the example, the nextMessage for the next processor is
initialized with the old NormalizedMessage instance and thus the header entry
won't vanish. Further, since the headers are the properties of the
NormalizedMessage instance, they are transmitted to the endpoints (tested with
JMS).
The javax.jbi.messaging.NormalizedMessage interface doesn't provide any methods
to remove properties -> I'm not sure how to solve this issue.
The current org.apache.servicemix.jbi.messaging.NormalizedMessageImpl, which
seems to be the standard implementation of the interface in servicemix, would
support the removal of a property if the value = null.
So in a custom processor one could write:
if(exchange instanceof JbiExchange) {
NormalizedMessage m = ((JbiExchange)exchange).getInMessage();
if(m instanceof NormalizedMessageImpl)
m.setProperty("test", null);
}
and the property is removed from the underlying HashMap.
One possible solution could be to implement the NormalizedMessage interfaces
based the org.apache.servicemix.jbi.messaging.NormalizedMessageImpl, override
the protected getter method for the property HashMap and implement a copy
constructor. The the JbiMessage could return the underlying HashMap in the
createHeaders() method.
Since the JbiMessage doesn't override the removeAttachment method the same
problem applies for attachments to, but can solved by overriding this method
and delegation the call to the NormalizedMessage.removeAttachment(String).
This bug seems to be related to
http://issues.apache.org/activemq/browse/SMXCOMP-569. Thus i looked at the fix,
but I think it won't fix this problem, because the fix overrides the
createHeaders() and createAttachments() methods and implements a custom put()
method for the returned HashMap.
To summarize it up one can't remove header entries or attachments once the are
added, but one can change them. The main problem is that the
javax.jbi.messaging.NormalizedMessage doesn't provide a method to remove
properties. I'm not sure if it should be fixed or if JBI doesn't intend to
support the removal of properties? For the attachments the JbiMessage must
override the removeAttachment(String).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.