-
Bug
-
Resolution: Done
-
Major
-
1.2.0.2-fuse
-
None
-
None
I'm trying to find a way to have amq topics automatically created with names taken from parts of the incoming message. I figured out a way to do that in DSL as follows:
from("jbi:endpoint:http://servicemix.apache.org/mycorp/camel-router/endpoint").recipientList(xquery("concat('activemq:topic:dynamicTopics/topic.',//Sample/Xquery/Expression[@PartyType=1]/@FacilityCode)").asString());
This works fine and topics are created correctly named as follows
If say, FacilityCode is "NYC", the topic will be created as:
dynamicTopics/topic.NYC
The problem arises when trying to do this in XML config. Given the following XML config file snippet:
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="jbi:endpoint:http://servicemix.apache.org/mycorp/camel-router/endpoint"/>
<recipientList>
<xquery>concat('activemq:topic:dynamicTopics/topic.',/,//Sample/Xquery/Expression[@PartyType=1]/@FacilityCode)</xquery>
</recipientList>
</route>
</camelContext>
Yields the following error when passing a message through the router:
ERROR - DeadLetterChannel - On delivery attempt: 0 caught: org.apache.camel.RuntimeExpressionException: net.sf.saxon.trans.DynamicError: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
org.apache.camel.RuntimeExpressionException: net.sf.saxon.trans.DynamicError: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at org.apache.camel.component.xquery.XQueryBuilder.evaluate(XQueryBuilder.java:124)
at org.apache.camel.processor.RecipientList.process(RecipientList.java:55)
at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:157)
at org.apache.servicemix.camel.CamelJbiEndpoint.processInOnly(CamelJbiEndpoint.java:64)
at org.apache.servicemix.common.endpoints.ProviderEndpoint.process(ProviderEndpoint.java:100)
at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
at org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:170)
at org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
at org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
Caused by: net.sf.saxon.trans.DynamicError: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at net.sf.saxon.dom.DOMEmitter.characters(DOMEmitter.java:122)
at net.sf.saxon.event.TreeReceiver.characters(TreeReceiver.java:173)
at net.sf.saxon.event.TreeReceiver.append(TreeReceiver.java:220)
at net.sf.saxon.pull.PullPushTee.copyEvent(PullPushTee.java:123)
at net.sf.saxon.pull.PullPushTee.next(PullPushTee.java:56)
at net.sf.saxon.pull.PullConsumer.consume(PullConsumer.java:27)
at net.sf.saxon.pull.PullPushCopier.copy(PullPushCopier.java:27)
at net.sf.saxon.query.XQueryExpression.pull(XQueryExpression.java:364)
at org.apache.camel.component.xquery.XQueryBuilder.evaluateAsDOM(XQueryBuilder.java:153)
at org.apache.camel.component.xquery.XQueryBuilder.evaluate(XQueryBuilder.java:113)
... 14 more
Caused by: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown Source)
at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown Source)
at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
at net.sf.saxon.dom.DOMEmitter.characters(DOMEmitter.java:120)
... 23 more