You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Suresh Inavolu <si...@progress.com> on 2008/10/02 17:05:21 UTC

Problem with Dynamic Recipient list and XPath

Hi, 

 

I am working on the dynamic recipient list, and have some problems :-(
with it.

 

The dynamic recipient list is throwing some exceptions while running -
here are the details

 

For this pattern (I am using Spring XML configuration instead of Java
DSL):

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <xpath>/root/addr/text()</xpath>

    </recipientList>

</route>

 

It is supposed to send the message to all the recipients listed in the
xpath /root/addr

 

So if this message is sent to the topic SampleT1,

<root>

            <addr>jms:queue:SampleQ1</addr>

            <addr>jms:queue:SampleQ2</addr>

            <moreDetails>...</moreDetails>

</root>

 

It should forward the same message to both SampleQ1 and SampleQ2. Is
this right?

 

But when I run it, it is giving the following exception: Even if I don't
use the text() function (just use the XPath /root/addr) it is giving an
error

 

org.apache.camel.RuntimeCamelException:
org.apache.camel.NoSuchEndpointException: No endpoint could be found
for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:71)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvo
keListener(AbstractMessageListenerContainer.java:531)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.invoke
Listener(AbstractMessageListenerContainer.java:466)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExec
uteListener(AbstractMessageListenerContainer.java:435)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java
:944)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.run(DefaultMessageListenerContainer.java:875)

      at java.lang.Thread.run(Thread.java:595)

Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could
be found for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelConte
xtHelper.java:54)

      at
org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java
:85)

      at
org.apache.camel.processor.RecipientList.resolveEndpoint(RecipientList.j
ava:74)

      at
org.apache.camel.processor.RecipientList.process(RecipientList.java:65)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:69)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:155)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:91)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:57)

      at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcess
or.java:39)

      at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
java:41)

      at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncP
rocessor.java:66)

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:68)

      ... 8 more

 

 

Also what is equivalent spring configuration for this DSL:

 

from("direct:a").recipientList(
        header("recipientListHeader").tokenize(","));

 

I can use a header expression but not the tokenizer,

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <header>$foo</header>

    </recipientList>

</route>

 

So what does the above pattern do? Get the list of all recipient list
from the header - but what is the default tokenize value?

 

Thanks

Suresh

 


Re: Problem with Dynamic Recipient list and XPath

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

I never wrote how it works. The header that it uses must be
Iterateable, so you can for instance add a List<String> with your
endpoints if you have multiple


List<String> destinations = new ArrayList<String>():
destinations.add("activemq:topic:foo");
destinations.add("activemq:topic:bar");

exchange.getIn().setHeader("myDestinationsHeader", destinations);




On Tue, Jan 13, 2009 at 1:08 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Ticket is
> https://issues.apache.org/activemq/browse/CAMEL-1251
>
> On Tue, Jan 13, 2009 at 12:59 PM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> I have looked into the code. I dont think it automatic tokenize using
>> comma. You have to add that manually. In spring DSL that can be kinda
>> hard. So I am working on improving this.
>>
>> At the same time the wiki needs a little update as well. Thanks.
>>
>>
>> On Mon, Jan 12, 2009 at 11:37 PM, ychawla <pr...@yahoo.com> wrote:
>>>
>>> Hello All,
>>> I was reading this thread and I had a similiar question to the original
>>> poster.  I have a simple spring route like this:
>>>
>>>      <recipientList>
>>>        <header>WorkflowRecipients</header>
>>>      </recipientList>
>>>
>>> And I set the header like this in code:
>>> message.setHeader("WorkflowRecipients",
>>> "activemq:Workflow1,activemq:Workflow2,activemq:Workflow3");
>>>
>>> It seems to automatically tokenize based on the ",".  This works great for
>>> me as I would like to multicast dynamically to all these recipients.  In the
>>> Spring Route, does RecipientList automatically tokenize based on "," and is
>>> this token configurable?  The WIKI could probably be brushed up based on
>>> this answer and I wouldn't mind doing it:
>>>
>>> http://activemq.apache.org/camel/recipient-list.html
>>>
>>> Thanks,
>>> Yogesh
>>> --
>>> View this message in context: http://www.nabble.com/Problem-with-Dynamic-Recipient-list-and-XPath-tp19781189s22882p21425421.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: Problem with Dynamic Recipient list and XPath

Posted by Claus Ibsen <cl...@gmail.com>.
Ticket is
https://issues.apache.org/activemq/browse/CAMEL-1251

On Tue, Jan 13, 2009 at 12:59 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> I have looked into the code. I dont think it automatic tokenize using
> comma. You have to add that manually. In spring DSL that can be kinda
> hard. So I am working on improving this.
>
> At the same time the wiki needs a little update as well. Thanks.
>
>
> On Mon, Jan 12, 2009 at 11:37 PM, ychawla <pr...@yahoo.com> wrote:
>>
>> Hello All,
>> I was reading this thread and I had a similiar question to the original
>> poster.  I have a simple spring route like this:
>>
>>      <recipientList>
>>        <header>WorkflowRecipients</header>
>>      </recipientList>
>>
>> And I set the header like this in code:
>> message.setHeader("WorkflowRecipients",
>> "activemq:Workflow1,activemq:Workflow2,activemq:Workflow3");
>>
>> It seems to automatically tokenize based on the ",".  This works great for
>> me as I would like to multicast dynamically to all these recipients.  In the
>> Spring Route, does RecipientList automatically tokenize based on "," and is
>> this token configurable?  The WIKI could probably be brushed up based on
>> this answer and I wouldn't mind doing it:
>>
>> http://activemq.apache.org/camel/recipient-list.html
>>
>> Thanks,
>> Yogesh
>> --
>> View this message in context: http://www.nabble.com/Problem-with-Dynamic-Recipient-list-and-XPath-tp19781189s22882p21425421.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: Problem with Dynamic Recipient list and XPath

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

I have looked into the code. I dont think it automatic tokenize using
comma. You have to add that manually. In spring DSL that can be kinda
hard. So I am working on improving this.

At the same time the wiki needs a little update as well. Thanks.


On Mon, Jan 12, 2009 at 11:37 PM, ychawla <pr...@yahoo.com> wrote:
>
> Hello All,
> I was reading this thread and I had a similiar question to the original
> poster.  I have a simple spring route like this:
>
>      <recipientList>
>        <header>WorkflowRecipients</header>
>      </recipientList>
>
> And I set the header like this in code:
> message.setHeader("WorkflowRecipients",
> "activemq:Workflow1,activemq:Workflow2,activemq:Workflow3");
>
> It seems to automatically tokenize based on the ",".  This works great for
> me as I would like to multicast dynamically to all these recipients.  In the
> Spring Route, does RecipientList automatically tokenize based on "," and is
> this token configurable?  The WIKI could probably be brushed up based on
> this answer and I wouldn't mind doing it:
>
> http://activemq.apache.org/camel/recipient-list.html
>
> Thanks,
> Yogesh
> --
> View this message in context: http://www.nabble.com/Problem-with-Dynamic-Recipient-list-and-XPath-tp19781189s22882p21425421.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: Problem with Dynamic Recipient list and XPath

Posted by ychawla <pr...@yahoo.com>.
Hello All,
I was reading this thread and I had a similiar question to the original
poster.  I have a simple spring route like this:

      <recipientList>
        <header>WorkflowRecipients</header>
      </recipientList>

And I set the header like this in code:
message.setHeader("WorkflowRecipients",
"activemq:Workflow1,activemq:Workflow2,activemq:Workflow3");

It seems to automatically tokenize based on the ",".  This works great for
me as I would like to multicast dynamically to all these recipients.  In the
Spring Route, does RecipientList automatically tokenize based on "," and is
this token configurable?  The WIKI could probably be brushed up based on
this answer and I wouldn't mind doing it:

http://activemq.apache.org/camel/recipient-list.html

Thanks,
Yogesh
-- 
View this message in context: http://www.nabble.com/Problem-with-Dynamic-Recipient-list-and-XPath-tp19781189s22882p21425421.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problem with Dynamic Recipient list and XPath

Posted by Jonathan Anstey <ja...@gmail.com>.
Hi Suresh,

You'll need to use Camel 1.5-SNAPSHOT to use a constant expression (see 
http://activemq.apache.org/camel/constant.html).

You can get nightly SNAPSHOTs here
http://people.apache.org/maven-snapshot-repository/org/apache/camel/apache-camel/1.5-SNAPSHOT/

Suresh Inavolu wrote:
> Hi,
>
> Thanks for information Claus.
>
> A queue with that name is present - I am able to run the other patterns with the queue name.
>
> Also I am unable to use the tag <constant>. 
> It is not recognizing this tag correctly. Problem with schema http://activemq.apache.org/camel/schema/spring/camel-spring.xsd? In the schema I don't find any element named "constant".
>
> When I try to run it, it giving an SAX Parser exception,
>
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from URL [file:/C:/Documents%20and%20Settings/sinavolu/runtime-New_configuration/RoutingSlip/sample_input-camel.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'constant'. One of '{"http://activemq.apache.org/camel/schema/spring":description, "http://activemq.apache.org/camel/schema/spring":el, "http://activemq.apache.org/camel/schema/spring":groovy, "http://activemq.apache.org/camel/schema/spring":header, "http://activemq.apache.org/camel/schema/spring":jxpath, "http://activemq.apache.org/camel/schema/spring":javaScript, "http://activemq.apache.org/camel/schema/spring":expression, "http://activemq.apache.org/camel/schema/spring":methodCall, "http://activemq.apache.org/camel/schema/spring":ognl, "http://activemq.apache.org/camel/schema/spring":php, "http://activemq.apache.org/camel/schema/spring":python, "http://activemq.apache.org/camel/schema/spring":ruby, "http://activemq.apache.org/camel/schema/spring":simple, "http://activemq.apache.org/camel/schema/spring":sql, "http://activemq.apache.org/camel/schema/spring":xpath, "http://activemq.apache.org/camel/schema/spring":xquery}' is expected.
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
> 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
>
> Thanks
> Suresh
>
> -----Original Message-----
> From: Claus Ibsen [mailto:ci@silverbullet.dk] 
> Sent: Thursday, October 02, 2008 12:36 PM
> To: camel-user@activemq.apache.org
> Subject: RE: Problem with Dynamic Recipient list and XPath
>
> Hi
>
> And if you use:
>
>     <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>
>
>     <recipientList>
>
>         <constant>jms:queue:SampleQ1</constant>
>
>     </recipientList>
>
>
> Just to be sure that the jms queue can be found?
>
> It looks like that the xpath is evaluated to a string "[#text: jms:queue:SampleQ1]" where it contains the [#text: ] stuff as it shouldn't. 
>
> BTW: What version of camel are you using?
>
> About the tokenizer: Maybe the Spring DSL has a missing feature there as well as you build your expression. And there is no default tonkenize. It's only used if you add it to your expression. In the sample it's used for a single header value, such as a String that is split using the tokenizer.
>
> In you case you use a xpath expression that does not need the tokenizer. It will still create something that can be iterated for the recipenetlist.
>
>
>
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
>
> -----Original Message-----
> From: Suresh Inavolu [mailto:sinavolu@progress.com] 
> Sent: 2. oktober 2008 17:05
> To: camel-user@activemq.apache.org
> Subject: Problem with Dynamic Recipient list and XPath
>
> Hi, 
>
>  
>
> I am working on the dynamic recipient list, and have some problems :-(
> with it.
>
>  
>
> The dynamic recipient list is throwing some exceptions while running -
> here are the details
>
>  
>
> For this pattern (I am using Spring XML configuration instead of Java
> DSL):
>
>  
>
> <route xmlns="http://activemq.apache.org/camel/schema/spring">
>
>     <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>
>
>     <recipientList>
>
>         <xpath>/root/addr/text()</xpath>
>
>     </recipientList>
>
> </route>
>
>  
>
> It is supposed to send the message to all the recipients listed in the
> xpath /root/addr
>
>  
>
> So if this message is sent to the topic SampleT1,
>
> <root>
>
>             <addr>jms:queue:SampleQ1</addr>
>
>             <addr>jms:queue:SampleQ2</addr>
>
>             <moreDetails>...</moreDetails>
>
> </root>
>
>  
>
> It should forward the same message to both SampleQ1 and SampleQ2. Is
> this right?
>
>  
>
> But when I run it, it is giving the following exception: Even if I don't
> use the text() function (just use the XPath /root/addr) it is giving an
> error
>
>  
>
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.NoSuchEndpointException: No endpoint could be found
> for: [#text: jms:queue:SampleQ1]
>
>       at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
> tMessageListener.java:71)
>
>       at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvo
> keListener(AbstractMessageListenerContainer.java:531)
>
>       at
> org.springframework.jms.listener.AbstractMessageListenerContainer.invoke
> Listener(AbstractMessageListenerContainer.java:466)
>
>       at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doExec
> uteListener(AbstractMessageListenerContainer.java:435)
>
>       at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer
> .doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
>
>       at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer
> .receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
>
>       at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
> ssageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java
> :944)
>
>       at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
> ssageListenerInvoker.run(DefaultMessageListenerContainer.java:875)
>
>       at java.lang.Thread.run(Thread.java:595)
>
> Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could
> be found for: [#text: jms:queue:SampleQ1]
>
>       at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelConte
> xtHelper.java:54)
>
>       at
> org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java
> :85)
>
>       at
> org.apache.camel.processor.RecipientList.resolveEndpoint(RecipientList.j
> ava:74)
>
>       at
> org.apache.camel.processor.RecipientList.process(RecipientList.java:65)
>
>       at
> org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
> tionProcessor.java:69)
>
>       at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
> ava:155)
>
>       at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
> ava:91)
>
>       at
> org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
> tionProcessor.java:57)
>
>       at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcess
> or.java:39)
>
>       at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
> java:41)
>
>       at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncP
> rocessor.java:66)
>
>       at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
> tMessageListener.java:68)
>
>       ... 8 more
>
>  
>
>  
>
> Also what is equivalent spring configuration for this DSL:
>
>  
>
> from("direct:a").recipientList(
>         header("recipientListHeader").tokenize(","));
>
>  
>
> I can use a header expression but not the tokenizer,
>
>  
>
> <route xmlns="http://activemq.apache.org/camel/schema/spring">
>
>     <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>
>
>     <recipientList>
>
>         <header>$foo</header>
>
>     </recipientList>
>
> </route>
>
>  
>
> So what does the above pattern do? Get the list of all recipient list
> from the header - but what is the default tokenize value?
>
>  
>
> Thanks
>
> Suresh
>
>  
>
>   



RE: Problem with Dynamic Recipient list and XPath

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

<constant> is only available in Camel 1.5 (work in progress)


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Suresh Inavolu [mailto:sinavolu@progress.com] 
Sent: 2. oktober 2008 20:45
To: camel-user@activemq.apache.org
Subject: RE: Problem with Dynamic Recipient list and XPath

Hi,

Thanks for information Claus.

A queue with that name is present - I am able to run the other patterns with the queue name.

Also I am unable to use the tag <constant>. 
It is not recognizing this tag correctly. Problem with schema http://activemq.apache.org/camel/schema/spring/camel-spring.xsd? In the schema I don't find any element named "constant".

When I try to run it, it giving an SAX Parser exception,

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from URL [file:/C:/Documents%20and%20Settings/sinavolu/runtime-New_configuration/RoutingSlip/sample_input-camel.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'constant'. One of '{"http://activemq.apache.org/camel/schema/spring":description, "http://activemq.apache.org/camel/schema/spring":el, "http://activemq.apache.org/camel/schema/spring":groovy, "http://activemq.apache.org/camel/schema/spring":header, "http://activemq.apache.org/camel/schema/spring":jxpath, "http://activemq.apache.org/camel/schema/spring":javaScript, "http://activemq.apache.org/camel/schema/spring":expression, "http://activemq.apache.org/camel/schema/spring":methodCall, "http://activemq.apache.org/camel/schema/spring":ognl, "http://activemq.apache.org/camel/schema/spring":php, "http://activemq.apache.org/camel/schema/spring":python, "http://activemq.apache.org/camel/schema/spring":ruby, "http://activemq.apache.org/camel/schema/spring":simple, "http://activemq.apache.org/camel/schema/spring":sql, "http://activemq.apache.org/camel/schema/spring":xpath, "http://activemq.apache.org/camel/schema/spring":xquery}' is expected.
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)

Thanks
Suresh

-----Original Message-----
From: Claus Ibsen [mailto:ci@silverbullet.dk] 
Sent: Thursday, October 02, 2008 12:36 PM
To: camel-user@activemq.apache.org
Subject: RE: Problem with Dynamic Recipient list and XPath

Hi

And if you use:

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <constant>jms:queue:SampleQ1</constant>

    </recipientList>


Just to be sure that the jms queue can be found?

It looks like that the xpath is evaluated to a string "[#text: jms:queue:SampleQ1]" where it contains the [#text: ] stuff as it shouldn't. 

BTW: What version of camel are you using?

About the tokenizer: Maybe the Spring DSL has a missing feature there as well as you build your expression. And there is no default tonkenize. It's only used if you add it to your expression. In the sample it's used for a single header value, such as a String that is split using the tokenizer.

In you case you use a xpath expression that does not need the tokenizer. It will still create something that can be iterated for the recipenetlist.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Suresh Inavolu [mailto:sinavolu@progress.com] 
Sent: 2. oktober 2008 17:05
To: camel-user@activemq.apache.org
Subject: Problem with Dynamic Recipient list and XPath

Hi, 

 

I am working on the dynamic recipient list, and have some problems :-(
with it.

 

The dynamic recipient list is throwing some exceptions while running -
here are the details

 

For this pattern (I am using Spring XML configuration instead of Java
DSL):

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <xpath>/root/addr/text()</xpath>

    </recipientList>

</route>

 

It is supposed to send the message to all the recipients listed in the
xpath /root/addr

 

So if this message is sent to the topic SampleT1,

<root>

            <addr>jms:queue:SampleQ1</addr>

            <addr>jms:queue:SampleQ2</addr>

            <moreDetails>...</moreDetails>

</root>

 

It should forward the same message to both SampleQ1 and SampleQ2. Is
this right?

 

But when I run it, it is giving the following exception: Even if I don't
use the text() function (just use the XPath /root/addr) it is giving an
error

 

org.apache.camel.RuntimeCamelException:
org.apache.camel.NoSuchEndpointException: No endpoint could be found
for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:71)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvo
keListener(AbstractMessageListenerContainer.java:531)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.invoke
Listener(AbstractMessageListenerContainer.java:466)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExec
uteListener(AbstractMessageListenerContainer.java:435)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java
:944)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.run(DefaultMessageListenerContainer.java:875)

      at java.lang.Thread.run(Thread.java:595)

Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could
be found for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelConte
xtHelper.java:54)

      at
org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java
:85)

      at
org.apache.camel.processor.RecipientList.resolveEndpoint(RecipientList.j
ava:74)

      at
org.apache.camel.processor.RecipientList.process(RecipientList.java:65)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:69)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:155)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:91)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:57)

      at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcess
or.java:39)

      at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
java:41)

      at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncP
rocessor.java:66)

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:68)

      ... 8 more

 

 

Also what is equivalent spring configuration for this DSL:

 

from("direct:a").recipientList(
        header("recipientListHeader").tokenize(","));

 

I can use a header expression but not the tokenizer,

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <header>$foo</header>

    </recipientList>

</route>

 

So what does the above pattern do? Get the list of all recipient list
from the header - but what is the default tokenize value?

 

Thanks

Suresh

 


RE: Problem with Dynamic Recipient list and XPath

Posted by Suresh Inavolu <si...@progress.com>.
Hi,

Thanks for information Claus.

A queue with that name is present - I am able to run the other patterns with the queue name.

Also I am unable to use the tag <constant>. 
It is not recognizing this tag correctly. Problem with schema http://activemq.apache.org/camel/schema/spring/camel-spring.xsd? In the schema I don't find any element named "constant".

When I try to run it, it giving an SAX Parser exception,

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 5 in XML document from URL [file:/C:/Documents%20and%20Settings/sinavolu/runtime-New_configuration/RoutingSlip/sample_input-camel.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'constant'. One of '{"http://activemq.apache.org/camel/schema/spring":description, "http://activemq.apache.org/camel/schema/spring":el, "http://activemq.apache.org/camel/schema/spring":groovy, "http://activemq.apache.org/camel/schema/spring":header, "http://activemq.apache.org/camel/schema/spring":jxpath, "http://activemq.apache.org/camel/schema/spring":javaScript, "http://activemq.apache.org/camel/schema/spring":expression, "http://activemq.apache.org/camel/schema/spring":methodCall, "http://activemq.apache.org/camel/schema/spring":ognl, "http://activemq.apache.org/camel/schema/spring":php, "http://activemq.apache.org/camel/schema/spring":python, "http://activemq.apache.org/camel/schema/spring":ruby, "http://activemq.apache.org/camel/schema/spring":simple, "http://activemq.apache.org/camel/schema/spring":sql, "http://activemq.apache.org/camel/schema/spring":xpath, "http://activemq.apache.org/camel/schema/spring":xquery}' is expected.
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)

Thanks
Suresh

-----Original Message-----
From: Claus Ibsen [mailto:ci@silverbullet.dk] 
Sent: Thursday, October 02, 2008 12:36 PM
To: camel-user@activemq.apache.org
Subject: RE: Problem with Dynamic Recipient list and XPath

Hi

And if you use:

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <constant>jms:queue:SampleQ1</constant>

    </recipientList>


Just to be sure that the jms queue can be found?

It looks like that the xpath is evaluated to a string "[#text: jms:queue:SampleQ1]" where it contains the [#text: ] stuff as it shouldn't. 

BTW: What version of camel are you using?

About the tokenizer: Maybe the Spring DSL has a missing feature there as well as you build your expression. And there is no default tonkenize. It's only used if you add it to your expression. In the sample it's used for a single header value, such as a String that is split using the tokenizer.

In you case you use a xpath expression that does not need the tokenizer. It will still create something that can be iterated for the recipenetlist.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Suresh Inavolu [mailto:sinavolu@progress.com] 
Sent: 2. oktober 2008 17:05
To: camel-user@activemq.apache.org
Subject: Problem with Dynamic Recipient list and XPath

Hi, 

 

I am working on the dynamic recipient list, and have some problems :-(
with it.

 

The dynamic recipient list is throwing some exceptions while running -
here are the details

 

For this pattern (I am using Spring XML configuration instead of Java
DSL):

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <xpath>/root/addr/text()</xpath>

    </recipientList>

</route>

 

It is supposed to send the message to all the recipients listed in the
xpath /root/addr

 

So if this message is sent to the topic SampleT1,

<root>

            <addr>jms:queue:SampleQ1</addr>

            <addr>jms:queue:SampleQ2</addr>

            <moreDetails>...</moreDetails>

</root>

 

It should forward the same message to both SampleQ1 and SampleQ2. Is
this right?

 

But when I run it, it is giving the following exception: Even if I don't
use the text() function (just use the XPath /root/addr) it is giving an
error

 

org.apache.camel.RuntimeCamelException:
org.apache.camel.NoSuchEndpointException: No endpoint could be found
for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:71)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvo
keListener(AbstractMessageListenerContainer.java:531)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.invoke
Listener(AbstractMessageListenerContainer.java:466)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExec
uteListener(AbstractMessageListenerContainer.java:435)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java
:944)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.run(DefaultMessageListenerContainer.java:875)

      at java.lang.Thread.run(Thread.java:595)

Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could
be found for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelConte
xtHelper.java:54)

      at
org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java
:85)

      at
org.apache.camel.processor.RecipientList.resolveEndpoint(RecipientList.j
ava:74)

      at
org.apache.camel.processor.RecipientList.process(RecipientList.java:65)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:69)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:155)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:91)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:57)

      at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcess
or.java:39)

      at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
java:41)

      at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncP
rocessor.java:66)

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:68)

      ... 8 more

 

 

Also what is equivalent spring configuration for this DSL:

 

from("direct:a").recipientList(
        header("recipientListHeader").tokenize(","));

 

I can use a header expression but not the tokenizer,

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <header>$foo</header>

    </recipientList>

</route>

 

So what does the above pattern do? Get the list of all recipient list
from the header - but what is the default tokenize value?

 

Thanks

Suresh

 


RE: Problem with Dynamic Recipient list and XPath

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

And if you use:

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <constant>jms:queue:SampleQ1</constant>

    </recipientList>


Just to be sure that the jms queue can be found?

It looks like that the xpath is evaluated to a string "[#text: jms:queue:SampleQ1]" where it contains the [#text: ] stuff as it shouldn't. 

BTW: What version of camel are you using?

About the tokenizer: Maybe the Spring DSL has a missing feature there as well as you build your expression. And there is no default tonkenize. It's only used if you add it to your expression. In the sample it's used for a single header value, such as a String that is split using the tokenizer.

In you case you use a xpath expression that does not need the tokenizer. It will still create something that can be iterated for the recipenetlist.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Suresh Inavolu [mailto:sinavolu@progress.com] 
Sent: 2. oktober 2008 17:05
To: camel-user@activemq.apache.org
Subject: Problem with Dynamic Recipient list and XPath

Hi, 

 

I am working on the dynamic recipient list, and have some problems :-(
with it.

 

The dynamic recipient list is throwing some exceptions while running -
here are the details

 

For this pattern (I am using Spring XML configuration instead of Java
DSL):

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <xpath>/root/addr/text()</xpath>

    </recipientList>

</route>

 

It is supposed to send the message to all the recipients listed in the
xpath /root/addr

 

So if this message is sent to the topic SampleT1,

<root>

            <addr>jms:queue:SampleQ1</addr>

            <addr>jms:queue:SampleQ2</addr>

            <moreDetails>...</moreDetails>

</root>

 

It should forward the same message to both SampleQ1 and SampleQ2. Is
this right?

 

But when I run it, it is giving the following exception: Even if I don't
use the text() function (just use the XPath /root/addr) it is giving an
error

 

org.apache.camel.RuntimeCamelException:
org.apache.camel.NoSuchEndpointException: No endpoint could be found
for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:71)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvo
keListener(AbstractMessageListenerContainer.java:531)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.invoke
Listener(AbstractMessageListenerContainer.java:466)

      at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExec
uteListener(AbstractMessageListenerContainer.java:435)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)

      at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer
.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java
:944)

      at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMe
ssageListenerInvoker.run(DefaultMessageListenerContainer.java:875)

      at java.lang.Thread.run(Thread.java:595)

Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could
be found for: [#text: jms:queue:SampleQ1]

      at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelConte
xtHelper.java:54)

      at
org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java
:85)

      at
org.apache.camel.processor.RecipientList.resolveEndpoint(RecipientList.j
ava:74)

      at
org.apache.camel.processor.RecipientList.process(RecipientList.java:65)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:69)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:155)

      at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.j
ava:91)

      at
org.apache.camel.management.InstrumentationProcessor.process(Instrumenta
tionProcessor.java:57)

      at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcess
or.java:39)

      at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
java:41)

      at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncP
rocessor.java:66)

      at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(Endpoin
tMessageListener.java:68)

      ... 8 more

 

 

Also what is equivalent spring configuration for this DSL:

 

from("direct:a").recipientList(
        header("recipientListHeader").tokenize(","));

 

I can use a header expression but not the tokenizer,

 

<route xmlns="http://activemq.apache.org/camel/schema/spring">

    <from uri="jms:topic:SampleT1" id="Camel_JMS_2"/>

    <recipientList>

        <header>$foo</header>

    </recipientList>

</route>

 

So what does the above pattern do? Get the list of all recipient list
from the header - but what is the default tokenize value?

 

Thanks

Suresh