Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache camel routing queues issue

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?

like image 626
Theo Avatar asked Feb 03 '26 23:02

Theo


1 Answers

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:

  1. 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.
  2. 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.
  3. 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).
  4. In the choice statement, myHeader is tested. In the secure case, jms:queue:QSecure and finally direct:actionApp is invoked.
like image 168
Peter Keller Avatar answered Feb 06 '26 03:02

Peter Keller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!