I am trying to receive DELIVER_SM from the smsc. The first snippet of code where the smpp route is created statically, works just fine. But later, I wanted to listen to more than one smpp routes which are dynamically created with credentials returned from a SQL query so I wrote the second snippet which I thought it would run fine but instead, the route doesn't get to the printPdus method where i can see the DELIVER_SM. The snippet doesn't work because it is not starting with smpp as a consumer from a "from uri="smpp://...""? How could I make something like this but with dynamically created smpp routes using spring.
<route id="Report-route">
<from uri="smpp://${pdus.systemid}#${pdus.address}:${pdus.port}?password=${pdus.password}" />
<to uri="bean:SmsReceiver?method=printPdus" />
</route>
<route id="Report-route">
<from uri="sql:{{sql.selectReceivingRoutes}}" />
<to uri="bean:SmsReceiver?method=createReceivingRoutes" />
<recipientList>
<header>receiverRoutes</header>
</recipientList>
<to uri="bean:SmsReceiver?method=printPdus" />
</route>
Related
I get suggestions of Multicast,where a single request is routed to multiple endpoints as the snippet below.But the requirement is sending multiple requests in parallel to a single endpoint.
<route>
<from uri="direct:start"/>
<multicast>
<to uri="mock:first"/>
<to uri="mock:second"/>
<to uri="mock:third"/>
</multicast>
</route>
You can use parallelProcessing option.
<route>
<from uri="direct:start"/>
<multicast parallelProcessing="true">
<to uri="mock:first"/>
<to uri="mock:second"/>
<to uri="mock:third"/>
</multicast>
</route>
I'm trying to do a request response call inside a route which is actually called from the outside in an request response way. Now it seems this is not working, it looks like the outer replyTo/correlation id is lost.
Following situation:
Client
jmsRequest to myFirstQueue with replyTo=temp://xyz
Route
<route id="foo">
<from uri="jms:myFirstQueue"/>
<to uri="debugProcessor1"/>
<to uri="jms:myNestedIn?replyTo=myNestedOut" pattern="InOut"/>
<to uri="debugProcessor2"/>
</route>
<route id="myNestedFoo">
<from uri="jms:myNestedIn"/>
<to uri="someDummyProcessor"/>
<to uri="jms:myNestedOut" pattern="InOnly"/>
</route>
In debugProcessor1 I still see JMSReplyTo correctly set to temp://xyz, unfortunately in debugProcessor2 this is lost and therefore the client does not get back the response.
Figured it out, my debug processors actually destroyed it, without them it works!
I have CXF endpoint. I have dedicated route defined for each operation and routing the request to appropriate routes using header.operation name with reciepient list.
For couple operations(routes), I have post request to JMS endpoint which gets processed by another application and response is recieved in another queue. I have to read response message and transform the message. My requesting thread(webservice call) would be waiting for the transformed message.
Currently after posting request, currently I have written my own processor which use spring jms template to read message. I came across few examples such as split routes but not sure how it will work for overall synchronous communication which has in between JMS communication.
You can find a JMX Request/Reply example here:
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
</bean>
<bean id="setResponseProcessor" class="org.apache.camel.itest.jetty.SetResponseProcessor"/>
<camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
<route>
<from uri="cxf://serverBean"/>
<to uri="jms:responseQueue"/>
</route>
<route>
<from uri="jms:responseQueue"/>
<process ref="setResponseProcessor"/>
</route>
</camelContext>
I'm trying to create an application that gets information from a browser and drops it in a queue. That data is then picked up from the queue and sent through an application for security. The security app should drop it in a different queue when it is done to be picked up by a separate action application.
Could anyone help me along with the routing? Basically, the route I'm looking for is:
Browser/UI -> Qnonsecure -> security app -> QSecure -> action app
What I understand now is the following:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:queue:QnonSecure"/>
<to uri="jms:queue:QSecure"/>
</route>
</camelContext>
How Can I change this to route to and from applications.
How do I send the input from the browser into QnonSecure? Also, where in my code do I call the security app between the QnonSecure and QSecure?
There is more than one possible solution. Take the following route as a starting point:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="restlet:http://localhost:8081/myApp?restletMethod=post"/>
<to uri="jms:queue:QnonSecure" pattern="InOut" />
<enrich uri="direct:securityApp"/>
<choice>
<when>
<simple>${header.myHeader} == "SECURE"</simple>
<to uri="jms:queue:QSecure" pattern="InOut" />
<to uri="direct:actionApp" />
</when>
<otherwise>
<!-- handle non valid requests -->
</otherwise>
</choice>
</route>
</camelContext>
Steps:
The browser sends a POST request to the Camel restlet component. This could be done via JavaScript, a link and/or just a ordinary submit button.
The body is sent to jms:queue:QnonSecure. As we use the InOut pattern, this is done in a synchronous manner and the response is fetched.
The response of jms:queue:QnonSecure is sent to direct:securityApp where the credentials are tested. If they are correct, the header myHeader is set to SECURE (or any other value).
In the choice statement, myHeader is tested. In the secure case, jms:queue:QSecure and finally direct:actionApp is invoked.
With the java JMS API, I got from a DB an array of bytes and then I'm sending it to an ActiveMQ as a javax.jms.BytesMessage. After that with camel I want to put the file on a location,
I have this route in camel:
<route>
<from uri="activemq:queue.fileOuput"/>
<convertBodyTo type="java.nio.ByteBuffer"/>
<to uri="file://C:/output/"/>
</route>
But my problem is that my file in c:\output\ directory, I got the file with the message id as the file name, like
queue-preVerificacion-fileoutput-ID-jmachine-57401-1347652410053-0-1-1-1-1
but I want to put the name I have in the database, like MyFile.xml.
I have tried to set a message property like fileName and file:name, and also I saw in the apache document that I need to put a header "org.apache.camel.file.name", but with jms I don't know how to do it.
So my question is how can I put a customized name in the camel route?
Thanks to all.
Just place the file name in the jms message (as a string property).
// Something like this if you send the message using plain java/jms:
msg.setStringProperty("filename","MyFile.xml");
..//Send msg
Then you can do something like this in camel
<to uri="file://C:/output/?fileName=${header.filename}"/>
you just need to set the "CamelFileName" header value (based on a message header, etc)
<route>
<from uri="activemq:queue.fileOuput"/>
<convertBodyTo type="java.nio.ByteBuffer"/>
<setHeader headerName="CamelFileName">
<constant>${header.fileName}</constant>
</setHeader>
<to uri="file://C:/output/"/>
</route>
I think "org.apache.camel.file.name" is for camel 1.x , in the 2.x version CamelFileName worked fine. But I wanted a more dynamic file name, name based on the content. This example using a processor worked well ( camel 2.18 )
<route>
<from uri="MQ:MY_Q_NAME" />
<process ref="MyMessageProcessor"/>
<to uri="file://E:\OUTPUT" />
</route>
Inside the Processor :
exchange.getIn().setHeader(Exchange.FILE_NAME, myFileName);