Bleach
Bleach

Reputation: 309

Apache Camel Multiple SQL Statements

I am getting a message that contains various stuff in it. From that message I generate multiple SQL statements and add them in a list. In my previous implementation it was not a problem and I was executing the statements one by one but I could not find whether it is possible or not doing the same thing with apache camel. Simply what I'm asking is, is it possible to execute multiple SQL statements with apache camel?

Something like below? PS: Each statement is different from each other usually.

`from(...).process(new Processor()).to(THIS IS WHERE MULTIPLE STATEMENTS GOES I ASSUME)`

Thanks in advance.

Upvotes: 1

Views: 955

Answers (2)

Bedla
Bedla

Reputation: 4919

Use Recipient List EIP to set list of target endpoints dynamically at run-time.

Slightly modify your Processor and prepare List of endpoints to header.

exchange.getIn().setHeader("MyListOfStatements", Arrays.asList(
    "sql:INSERT something INTO somewhere", 
    "sql:INSERT anything INTO elsewhere"
));

Then use this header as Expression in recipientList

from(...).process(new Processor()).recipientList(header("MyListOfStatements"));

Upvotes: 1

Sneharghya Pathak
Sneharghya Pathak

Reputation: 1060

You can use the camel loop eip and each loop you can use the loop index to fetch the sql statement from the list and execute it.

Upvotes: 0

Related Questions