You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ignat <iz...@gmail.com> on 2012/08/01 16:59:14 UTC

Issue with JMS endpoint & headers that do not conform to JMS spec

Hello,

I think I've run into certain issue with camel - normally it allows almost
any header names, but JMS spec is quite restrictive about it (taken from JMS
1.1 3.8.1.1 paragraph, page 42):

Identifiers:
- An identifier is an unlimited-length character sequence that must begin
with a Java identifier start character; all following characters must be
Java identifier part characters. An identifier start character is any
character for which the method Character.isJavaIdentifierStart returns true.
This includes ‘_’ and ‘$’. An identifier part character is any character for
which the method Character.isJavaIdentifierPart returns true.
- Identifiers cannot be the names NULL, TRUE, or FALSE.
..... (formal naming rules about reserved identifiers are skipped) ...

So, for example, Foo://Bar&baz is valid header for using within camel route,
but it won't pass JMS provider validation for identifier correctness.

This issue is hidden in Camel to certain degree, since identifiers like
foo-bar will be auto-magically transformed into foo_HYPEN_bar, but this
transformation does not affect whole range of possible values.

My current workaround is to actually strip all message's headers that do not
conform to quoted spec, but some policy of auto-magical header's
transformation (from incoming messages and for outgoing messages) could be
potentially useful.

For some reason I cannot find any code in camel trunk that ignores header
names that are not conforming to be java identifiers (looked into 
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
shouldOutputHeader and
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsHeaderFilterStrategy.java
and DefaultHeaderFilterStrategy) so I presume this is just an oversight.

Also current behaviour contradicts to http://camel.apache.org/jms.html
Message Header Mapping wiki section.

Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-JMS-endpoint-headers-that-do-not-conform-to-JMS-spec-tp5716665.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with JMS endpoint & headers that do not conform to JMS spec

Posted by Babak Vahdat <ba...@swissonline.ch>.
I updated the Wiki regarding this which will be synched in one hour or so.
For now you find the updated revision here:

http://camel.465427.n5.nabble.com/CONF-Apache-Camel-gt-JMS-td5716667.html

Babak



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-JMS-endpoint-headers-that-do-not-conform-to-JMS-spec-tp5716665p5716669.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with JMS endpoint & headers that do not conform to JMS spec

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

It's the JMS broker's duty to be complaint to the JMS spec and not Camel
itself which is just a mediator of exchanges between endpoints, JMS broker
being just one of them.

So for example in case you make use of Apache ActiveMQ then you're "lucky"
as there's no restriction about the header values because the following
ticket has not been fixed (mainly because of the backward compatibility):

https://issues.apache.org/jira/browse/AMQ-2287

So just give your used broker a test to see how it behaves.

Babak



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-JMS-endpoint-headers-that-do-not-conform-to-JMS-spec-tp5716665p5716666.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with JMS endpoint & headers that do not conform to JMS spec

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Its documented on the Camel JMS page about the JMS spec limitations on
header keys / header value types etc
http://camel.apache.org/jms


Also see the option jmsKeyFormatStrategy where you can provide a custom strategy



On Wed, Aug 1, 2012 at 4:59 PM, Ignat <iz...@gmail.com> wrote:
> Hello,
>
> I think I've run into certain issue with camel - normally it allows almost
> any header names, but JMS spec is quite restrictive about it (taken from JMS
> 1.1 3.8.1.1 paragraph, page 42):
>
> Identifiers:
> - An identifier is an unlimited-length character sequence that must begin
> with a Java identifier start character; all following characters must be
> Java identifier part characters. An identifier start character is any
> character for which the method Character.isJavaIdentifierStart returns true.
> This includes ‘_’ and ‘$’. An identifier part character is any character for
> which the method Character.isJavaIdentifierPart returns true.
> - Identifiers cannot be the names NULL, TRUE, or FALSE.
> ..... (formal naming rules about reserved identifiers are skipped) ...
>
> So, for example, Foo://Bar&baz is valid header for using within camel route,
> but it won't pass JMS provider validation for identifier correctness.
>
> This issue is hidden in Camel to certain degree, since identifiers like
> foo-bar will be auto-magically transformed into foo_HYPEN_bar, but this
> transformation does not affect whole range of possible values.
>
> My current workaround is to actually strip all message's headers that do not
> conform to quoted spec, but some policy of auto-magical header's
> transformation (from incoming messages and for outgoing messages) could be
> potentially useful.
>
> For some reason I cannot find any code in camel trunk that ignores header
> names that are not conforming to be java identifiers (looked into
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
> shouldOutputHeader and
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsHeaderFilterStrategy.java
> and DefaultHeaderFilterStrategy) so I presume this is just an oversight.
>
> Also current behaviour contradicts to http://camel.apache.org/jms.html
> Message Header Mapping wiki section.
>
> Thanks.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issue-with-JMS-endpoint-headers-that-do-not-conform-to-JMS-spec-tp5716665.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen