简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM