Apache Camel Route Multicast does not copy the exchange message - copy

i made a camel route in my application with spring dsl.I want to copy the exchange body with using multicast EIP.But when i use this, i can take the exchange bodyfrom one of my endpoint.In the second one (which is endpoint in multicast ) ,the exchange body is null.Why this is happening like this?
EDIT
This is my route:
<route errorHandlerRef="dlc1" id="mobitRoute1">
<from uri="cxf:bean:mobit-okuma?dataFormat=PAYLOAD" />
<wireTap uri="activemq:queue:anaMobitQueue" />
<to uri="velocity:response.vm" />
</route>
<route id="mobitRoute2" errorHandlerRef="dlc2">
<from uri="activemq:queue:anaMobitQueue" />
<unmarshal ref="myJaxb" />
<to uri="bean:timeChanging" />
<multicast>
<to uri="activemq:queue:mobitOkumaq" />
<to uri="activemq:queue:AysMobit" />
</multicast>
</route>
<route errorHandlerRef="dlc3" id="mobitRoute3">
<from uri="activemq:queue:AysMobit" />
<!-- <unmarshal ref="myJaxb" /> -->
<to uri="bean:fromPayload" />
<to uri="cxf:bean:ays-service?dataFormat=POJO" />
</route>
<route errorHandlerRef="dlc4" id="mobitRoute4">
<from uri="activemq:queue:mobitOkumaq" />
<to uri="cxf:bean:mobit-okumaReal?dataFormat=POJO" />
</route>

I found the solution by transforming xml when i put the exchange to the queue.This is why ? I don't know.
<route errorHandlerRef="dlc1" id="mobitRoute1">
<from uri="cxf:bean:mobit-okuma?dataFormat=PAYLOAD" />
<wireTap uri="activemq:queue:anaMobitQueue" />
<to uri="velocity:response.vm" />
</route>
<route errorHandlerRef="dlc1" id="mobitRoute2">
<from uri="activemq:queue:anaMobitQueue" />
<camel:pipeline>
<unmarshal ref="myJaxb" />
<to uri="bean:timeChanging" />
<!-- <to uri="direct:unmarshalled"/> -->
<marshal ref="myJaxb" />
<camel:multicast>
<to uri="activemq:queue:BegisMobit" />
<to uri="activemq:queue:AysMobit" />
</camel:multicast>
</camel:pipeline>
</route>
<route errorHandlerRef="dlc2" id="mobitRoute3">
<from uri="activemq:queue:AysMobit" />
<unmarshal ref="myJaxb" />
<to uri="bean:fromPayload" />
<to uri="cxf:bean:ays-service?dataFormat=POJO" />
</route>
<route errorHandlerRef="dlc3" id="mobitRoute4">
<from uri="activemq:queue:BegisMobit" />
<unmarshal ref="myJaxb" />
<to uri="cxf:bean:mobit-okumaReal?dataFormat=POJO" />
</route>

Related

NoTypeConversionAvailableException: camel rest dsl

I have a web service like this:
<camelContext id="camel-CallAPI" xmlns="http://camel.apache.org/schema/blueprint" >
<!--Web service starts working -->
<restConfiguration bindingMode="auto" component="restlet" host="localhost" port="8889"/>
<rest path="/check">
<post uri="/version" consumes="application/json" produces="application/json">
<to uri="direct:first"/>
</post>
</rest>
<route>
<from uri="direct:first"/>
<setHeader headerName="Content-Type" id="header_contentType">
<constant>application/json</constant>
</setHeader>
<log message="after set header :: ${body}"/>
<to uri="http4://..."/>
<convertBodyTo type="java.lang.String"/>
<log message="the result of the testCheckLastVersion :: ${body}"/>
I'm sending a json content to this web service with the help of postman, and I need my web service to send that json to another API that has been mentioned in direct:first.
but when I call my web service in postman an error is happening:
org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: {version=apk.1.10.0} of type: java.util.LinkedHashMap on: Message[ID-localhost-localdomain-1549348033140-14-4]. Caused by: No type converter available to convert from type: java.util.LinkedHashMap to the required type: java.io.InputStream with value {version=apk.1.10.0}.
can any one help me with this?
I found the solution, the exception caused because I was set the bindingMode="auto" in camelContext which was not suitable here, by removing that, the problem solved.
<camelContext id="camel-CallAPI" xmlns="http://camel.apache.org/schema/blueprint" >
<!--Web service starts working -->
<restConfiguration component="restlet" host="localhost" port="8889"/>
<rest path="/say">
<post uri="/hi" consumes="application/json" produces="application/json">
<to uri="direct:first"/>
</post>
</rest>
<route>
<from uri="direct:first"/>
<setHeader headerName="Content-Type" id="_setHeader2">
<constant>application/json</constant>
</setHeader>
<to uri="http4://..."/>
<convertBodyTo type="java.lang.String"/>
<log message="the result of the testCheckLastVersion :: ${body}"/>
</route>
</camelContext>

Routing acording to xml nodename

<Body>
<ProductMasterDataStatus>
<Status>INVALID</Status>
<Errors>
<Error source="HUB">
<Description>Data Validation Error (Product code length is invalid.)</Description>
<Code>#A16</Code>
</Error>
</Errors>
</ProductMasterDataStatus>
</Body>
I want to check the ProductMasterDataStatus is in this xml if it is there i want to change the route in camel route.
<camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/spring">
<route id="_route1">
<from id="_from1" uri="file:///d:/in"/>
<camel:choice id="_choice1">
<camel:when id="_when1">
<camel:xpath>
</camel:xpath>
<camel:to id="_to1" uri="file:C:/outbox_Denmark"/>
</camel:when>
<process id="_process_transform" ref="myTransform"/>
<to id="_to1" uri="file:///d:/out?fileName=Product.xml"/>
</route>
The xpath expression is //ProductMasterDataStatus, so you should check if this is not null.
<camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/spring">
<route id="_route1">
<from id="_from1" uri="file:///d:/in"/>
<camel:choice id="_choice1">
<camel:when id="_when1">
<camel:xpath>//ProductMasterDataStatus != null</camel:xpath>
<camel:to id="_to1" uri="file:C:/outbox_Denmark"/>
</camel:when>
<process id="_process_transform" ref="myTransform"/>
<to id="_to1" uri="file:///d:/out?fileName=Product.xml"/>
</route>

How to set a message payload to a apache camel rest request

I need to set a JSON content as the message payload of a apache camel rest request. I tried it as follows. But it doesn't work.
<rest path="/service" consumes="application/json" produces="application/json">
<put type="com.xxxx.yyyyy.esb.models.UserServiceMapping"
uri="/create">
<route>
<log message="${body.serviceUrl}" />
<log message="${body.mappedServiceObject}" />
<log message="${body.systemUserDetails.userName}" />
<log message="${body.systemUserDetails.password}" />
<setBody> <simple>{"${body.mappedServiceObject}":{"userName" :
"${body.userName}", "password" : "${body.password}"}} </simple> </setBody>
<setHeader headerName="CamelRestletLogin">
<simple>admin</simple>
</setHeader>
<setHeader headerName="CamelRestletPassword">
<simple>admin</simple>
</setHeader>
<to
uri="restlet:http://xxx.xxx.x.xx:8081/xxxxxx/services/yyyyyyy/V1.0/users/create?restletMethod=POST" />
</route>
</put>
</rest>

How To exit from a Loop In Apache camel/Jboss

I need to exit from a loop when the body contains 'SUCCEDDED' in Jboss/Apache camel. I have tried using Stop() but that doesnt work since it stops every connection(eg:DBConnection).
Here is the sample code:
60
10000
${body}
contains 'SUCCEEDED'
<CXF bean call />
<log loggingLevel="INFO"
message="response
: ${body}">
<description>Logs the 2nd SOAP Response.</description>
</log>
<setBody>
<xpath>{{status.xpath}}</xpath>
</setBody>
<convertBodyTo type="java.lang.String" />
</otherwise>
</choice>
</loop>
<to uri="direct:loopend">
</to>
</route>

Why openfire return redundant message archiving?

I am using these technologies:
openfire version: 3.9.3
Monitoring Service plugin: 1.4.2
strophe.js: 1.1.3
I sent iq below for querying message archiving
<iq xmlns="jabber:client" type="get" id="2:retrieve">
<retrieve xmlns="urn:xmpp:archive" with="room123#conference.gunblues" start="2015-01-20T06:53:01.831Z">
<set xmlns="http://jabber.org/protocol/rsm" />
</retrieve>
</iq>
the result I want:
<iq xmlns="jabber:client" type="result" id="2:retrieve" to="user1#gunblues/e6432422">
<chat xmlns="urn:xmpp:archive" with="room123#conference.gunblues" start="2015-01-20T06:53:01.831Z">
<from secs="0" jid="user2#gunblues">
<body>abc</body>
</from>
<from secs="1" jid="user2#gunblues">
<body>a2</body>
</from>
<from secs="2" jid="user2#gunblues">
<body>a3</body>
</from>
<from secs="3" jid="user2#gunblues">
<body>a4</body>
</from>
<from secs="4" jid="user2#gunblues">
<body>a5</body>
</from>
<from secs="5" jid="user2#gunblues">
<body>a6</body>
</from>
<from secs="7" jid="user2#gunblues">
<body>a7</body>
</from>
<from secs="7" jid="user2#gunblues">
<body>a8</body>
</from>
<from secs="8" jid="user2#gunblues">
<body>a9</body>
</from>
<from secs="9" jid="user2#gunblues">
<body>a10</body>
</from>
<set xmlns="http://jabber.org/protocol/rsm">
<first index="0">0</first>
<last>9</last>
<count>10</count>
</set>
</chat>
</iq>
but server returned redundant result:
<iq xmlns="jabber:client" type="result" id="2:retrieve" to="user1#gunblues/e6432422">
<chat xmlns="urn:xmpp:archive" with="room123#conference.gunblues" start="2015-01-20T06:53:01.831Z">
<from secs="0" jid="user2#gunblues">
<body>abc</body>
</from>
<from secs="0" jid="user2#gunblues">
<body>abc</body>
</from>
<from secs="0" jid="user2#gunblues">
<body>abc</body>
</from>
<from secs="1" jid="user2#gunblues">
<body>a2</body>
</from>
<from secs="1" jid="user2#gunblues">
<body>a2</body>
</from>
<from secs="1" jid="user2#gunblues">
<body>a2</body>
</from>
<from secs="2" jid="user2#gunblues">
<body>a3</body>
</from>
<from secs="2" jid="user2#gunblues">
<body>a3</body>
</from>
<from secs="2" jid="user2#gunblues">
<body>a3</body>
</from>
<from secs="3" jid="user2#gunblues">
<body>a4</body>
</from>
<from secs="3" jid="user2#gunblues">
<body>a4</body>
</from>
<from secs="3" jid="user2#gunblues">
<body>a4</body>
</from>
<set xmlns="http://jabber.org/protocol/rsm">
<first index="0">0</first>
<last>11</last>
<count>12</count>
</set>
</chat>
</iq>