You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sailaja p <sp...@progress.com> on 2009/02/11 05:00:32 UTC

Re: Resequencer based on XML Message header element (MessageId)

Hi,

I am also getting the same exception (java.lang.ClassCastException) when I
ran the Spring XML with Resquencer Pattern.
 
I had even tried by adding the convertBodyTo tag with type="java.lang.Long"
as suggested by Martin. But still I am getting the same ClassCastException.
 

Below is the Spring XML File I used. I am using Camel 1.5.
 
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"><camelContext
id="camelroute" xmlns="http://activemq.apache.org/camel/schema/spring">
 <route xmlns="http://activemq.apache.org/camel/schema/spring">
     <from
uri="file:///D:/TeamCity/workspace/Sampel/EIP/Sender?autoCreate=false&amp;noop=true"
id="Camel_File_2"/>
     <resequencer id="Camel_Resequencer_4">
     	<xpath>/Sample/test</xpath>
     	<convertBodyTo type="java.lang.Long"></convertBodyTo>
         <to uri="file:///D:/TeamCity/workspace/Sampel/EIP"
id="Camel_File_6"/>
         <stream-config timeout="3000" capacity="3"/>
     </resequencer>
 </route>
</camelContext></beans>

Am I missing something, please let me know. Please help me in resolving the
problem.

Regards,
Sailaja.



rmunjuluri wrote:
> 
> Hello,
> 
> I am trying of the Resequencer EIP in camel and sending simple XML
> messages with in random order.
> 
> [java] INFO  [ActiveMQOnewaySender] Sending (0)- <MessageId>1</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (1)- <MessageId>6</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (2)- <MessageId>7</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (3)- <MessageId>4</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (4)- <MessageId>8</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (5)- <MessageId>2</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (6)- <MessageId>5</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (7)- <MessageId>0</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (8)- <MessageId>3</MessageId>
> [java] INFO  [ActiveMQOnewaySender] Sending (9)- <MessageId>9</MessageId>
> 
> As per my understanding I should be able to receive the messages at the
> other end in a resequenced order. the issue I have is I didnt find any
> samples XPATH expressions I could use to set in the camel route. I came
> across the jbi.Message based resequence expressions but not for XML
> messages. Is it possible at all to resequence based on XML message headers
> flowing in ServiceMix? or didnt I look at the right place for the a sample
> that does this?
> 
> thanx
> -ram
> 

-- 
View this message in context: http://www.nabble.com/Resequencer-based-on-XML-Message-header-element-%28MessageId%29-tp17454593s22882p21947981.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Resequencer based on XML Message header element (MessageId)

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

Could you paste the stacktrace with the class cast exception?


On Wed, Feb 11, 2009 at 5:00 AM, sailaja p <sp...@progress.com> wrote:
>
> Hi,
>
> I am also getting the same exception (java.lang.ClassCastException) when I
> ran the Spring XML with Resquencer Pattern.
>
> I had even tried by adding the convertBodyTo tag with type="java.lang.Long"
> as suggested by Martin. But still I am getting the same ClassCastException.
>
>
> Below is the Spring XML File I used. I am using Camel 1.5.
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"><camelContext
> id="camelroute" xmlns="http://activemq.apache.org/camel/schema/spring">
>  <route xmlns="http://activemq.apache.org/camel/schema/spring">
>     <from
> uri="file:///D:/TeamCity/workspace/Sampel/EIP/Sender?autoCreate=false&amp;noop=true"
> id="Camel_File_2"/>
>     <resequencer id="Camel_Resequencer_4">
>        <xpath>/Sample/test</xpath>
>        <convertBodyTo type="java.lang.Long"></convertBodyTo>
>         <to uri="file:///D:/TeamCity/workspace/Sampel/EIP"
> id="Camel_File_6"/>
>         <stream-config timeout="3000" capacity="3"/>
>     </resequencer>
>  </route>
> </camelContext></beans>
>
> Am I missing something, please let me know. Please help me in resolving the
> problem.
>
> Regards,
> Sailaja.
>
>
>
> rmunjuluri wrote:
>>
>> Hello,
>>
>> I am trying of the Resequencer EIP in camel and sending simple XML
>> messages with in random order.
>>
>> [java] INFO  [ActiveMQOnewaySender] Sending (0)- <MessageId>1</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (1)- <MessageId>6</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (2)- <MessageId>7</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (3)- <MessageId>4</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (4)- <MessageId>8</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (5)- <MessageId>2</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (6)- <MessageId>5</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (7)- <MessageId>0</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (8)- <MessageId>3</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (9)- <MessageId>9</MessageId>
>>
>> As per my understanding I should be able to receive the messages at the
>> other end in a resequenced order. the issue I have is I didnt find any
>> samples XPATH expressions I could use to set in the camel route. I came
>> across the jbi.Message based resequence expressions but not for XML
>> messages. Is it possible at all to resequence based on XML message headers
>> flowing in ServiceMix? or didnt I look at the right place for the a sample
>> that does this?
>>
>> thanx
>> -ram
>>
>
> --
> View this message in context: http://www.nabble.com/Resequencer-based-on-XML-Message-header-element-%28MessageId%29-tp17454593s22882p21947981.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/

Re: Resequencer based on XML Message header element (MessageId)

Posted by Martin Krasser <de...@martin-krasser.de>.
Hi,

the expression to extract the sequence number must return a 
java.lang.Long object. This doesn't seem to be the case for

<xpath>/Sample/test</xpath>

and therefore the default comparator 
(org.apache.camel.processor.resequencer.DefaultExchangeComparator) 
throws a ClassCastException. Either use another expression returning 
long values or use a custom comparator. However, using a custom 
comparator that can also compare sequence numbers other than Long can 
currently only be set via the Java DSL.

Another thing that might cause problems in your configuration is that 
you set the capacity to 3 which is far to low for most use cases.  Maybe 
you want to use the default values (see also the resequencer docs).

Hope that helps,
Martin

sailaja p schrieb:
> Hi,
>
> I am also getting the same exception (java.lang.ClassCastException) when I
> ran the Spring XML with Resquencer Pattern.
>  
> I had even tried by adding the convertBodyTo tag with type="java.lang.Long"
> as suggested by Martin. But still I am getting the same ClassCastException.
>  
>
> Below is the Spring XML File I used. I am using Camel 1.5.
>  
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"><camelContext
> id="camelroute" xmlns="http://activemq.apache.org/camel/schema/spring">
>  <route xmlns="http://activemq.apache.org/camel/schema/spring">
>      <from
> uri="file:///D:/TeamCity/workspace/Sampel/EIP/Sender?autoCreate=false&amp;noop=true"
> id="Camel_File_2"/>
>      <resequencer id="Camel_Resequencer_4">
>      	<xpath>/Sample/test</xpath>
>      	<convertBodyTo type="java.lang.Long"></convertBodyTo>
>          <to uri="file:///D:/TeamCity/workspace/Sampel/EIP"
> id="Camel_File_6"/>
>          <stream-config timeout="3000" capacity="3"/>
>      </resequencer>
>  </route>
> </camelContext></beans>
>
> Am I missing something, please let me know. Please help me in resolving the
> problem.
>
> Regards,
> Sailaja.
>
>
>
> rmunjuluri wrote:
>   
>> Hello,
>>
>> I am trying of the Resequencer EIP in camel and sending simple XML
>> messages with in random order.
>>
>> [java] INFO  [ActiveMQOnewaySender] Sending (0)- <MessageId>1</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (1)- <MessageId>6</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (2)- <MessageId>7</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (3)- <MessageId>4</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (4)- <MessageId>8</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (5)- <MessageId>2</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (6)- <MessageId>5</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (7)- <MessageId>0</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (8)- <MessageId>3</MessageId>
>> [java] INFO  [ActiveMQOnewaySender] Sending (9)- <MessageId>9</MessageId>
>>
>> As per my understanding I should be able to receive the messages at the
>> other end in a resequenced order. the issue I have is I didnt find any
>> samples XPATH expressions I could use to set in the camel route. I came
>> across the jbi.Message based resequence expressions but not for XML
>> messages. Is it possible at all to resequence based on XML message headers
>> flowing in ServiceMix? or didnt I look at the right place for the a sample
>> that does this?
>>
>> thanx
>> -ram
>>
>>     
>
>