Hugo Deiró
Hugo Deiró

Reputation: 224

How to use asynchronous routes in Apache Camel Blueprint

I have a route that has to be asynchronously consumed and I'm using an direct component to refers to it as an alias.

    <route id="producer_CUSTOMER_INTERACTIONS_ISSUES_RELATIONSHIPS_Topic">
        <from uri="direct:test"/>
        <pollEnrich aggregateOnException="false" id="pollEnrich1" timeout="-1">
            <constant>file:mock/customer-interactions-issues-relationships?noop=true&amp;idempotent=false</constant>
        </pollEnrich>
        <to uri="kafka:customer-interactions-issues-relationships?brokers=localhost:9092"/>
    </route>

That route has to be consumed by:

<route id="1"><from uri="timer://foo?fixedRate=true&amp;period=1&amp;repeatCount=1000"/><to uri="direct:test"/></route>
<route id="2"><from uri="timer://foo?fixedRate=true&amp;period=1&amp;repeatCount=1000"/><to uri="direct:test"/></route>
<route id="3"><from uri="timer://foo?fixedRate=true&amp;period=1&amp;repeatCount=1000"/><to uri="direct:test"/></route>
<route id="4"><from uri="timer://foo?fixedRate=true&amp;period=1&amp;repeatCount=1000"/><to uri="direct:test"/></route>

I would like that each consumer route requests 1000x the mock content of producer_CUSTOMER_INTERACTIONS_ISSUES_RLATIONSHIPS_Topic asyncrhonously, but, right now, it's syncrhonous as follows:

enter image description here

I've read about a SEDA component in Camel Documentation, but there isn't any example about how to use it in Blueprints :(

Upvotes: 0

Views: 917

Answers (1)

Hugo Deir&#243;
Hugo Deir&#243;

Reputation: 224

In order to help other people that need to do something like this, I've solved this problem using:

<route id="1"><from uri="timer://foo?fixedRate=true&amp;period=1&amp;repeatCount=1000&amp;delay=-1"/><to uri="direct:test"/></route>

I just added delay=-1 to force it run asynchronously.

I really don't know if it is the beast approach. If someone else has a better answer, please, post it to help =)

Upvotes: 1

Related Questions