How do I sync camel route processing with Java application?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I sync camel route processing with Java application?

Gagnon, Joseph - 0553 - MITLL

Hello,

 

I have a Java application that sends a series of test messages from a test injector to a target “service”. The means of message transport and data format is handled by a third party “service bus”. I am attempting to use Camel to assist with message capture (sent from the service bus), modifying the captured message and forwarding on to the target. Following is an outline of the processing flow:

 

Read in and parse XML message

For each element or attribute

                Determine a set of test cases to use

                For each test case

                                Send message via service bus

                                Intercept message (via Camel)

                                Replace original element/attribute content with test data

                                Forward message to target

 

The means by which I’m doing this is that I have written a Camel route like the following:

 

interceptSendToEndpoint(destURI).process(interceptor);

from(sourceURI).to(destURI);

 

The interceptor is an extension of org.apache.camel.Processor. The process() method retrieves the exchange body and performs the modification of the message by means of information (we’ll call it the discovery data) that I pass to the interceptor from my test injector. The process() method checks to see if the discovery data has been set, otherwise it just returns. If the discovery data is not null, the modification is performed and the modified data placed back in the exchange body. Then the discovery data is then set to null in the interceptor.

 

The Problem

 

All of this appears to be working as I need, except for the first test case. In this instance, process() always reports that the discovery data is null, even though I am always setting the discovery data into the interceptor before invoking the service bus message send.

 

My suspicion is that I am over-running a prior test case that hasn’t been received and processed “soon enough” before the next test case comes along and clobbers it. I need some way to have my injector logic wait until Camel intercepts the data of the prior test case, processes it and forwards it on to the target.

 

I’m looking for suggestions on how I might go about that. I don’t know enough about Camel to know what (if any) mechanisms are available that could help.

 

Thanks,

Joe Gagnon


smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How do I sync camel route processing with Java application?

Claus Ibsen-2
Hi

Did you get further with this?

Do you say that the injector sets the test-date "a bit too late" on
the 1st test case, or can you try to explain a bit more about that
problem? Your description is abstract (which is good) but sometimes
its also easier to help with a bit more code/example data.


On Tue, Jul 24, 2018 at 3:31 PM, Gagnon, Joseph - 0553 - MITLL
<[hidden email]> wrote:

> Hello,
>
>
>
> I have a Java application that sends a series of test messages from a test
> injector to a target “service”. The means of message transport and data
> format is handled by a third party “service bus”. I am attempting to use
> Camel to assist with message capture (sent from the service bus), modifying
> the captured message and forwarding on to the target. Following is an
> outline of the processing flow:
>
>
>
> Read in and parse XML message
>
> For each element or attribute
>
>                 Determine a set of test cases to use
>
>                 For each test case
>
>                                 Send message via service bus
>
>                                 Intercept message (via Camel)
>
>                                 Replace original element/attribute content
> with test data
>
>                                 Forward message to target
>
>
>
> The means by which I’m doing this is that I have written a Camel route like
> the following:
>
>
>
> interceptSendToEndpoint(destURI).process(interceptor);
>
> from(sourceURI).to(destURI);
>
>
>
> The interceptor is an extension of org.apache.camel.Processor. The process()
> method retrieves the exchange body and performs the modification of the
> message by means of information (we’ll call it the discovery data) that I
> pass to the interceptor from my test injector. The process() method checks
> to see if the discovery data has been set, otherwise it just returns. If the
> discovery data is not null, the modification is performed and the modified
> data placed back in the exchange body. Then the discovery data is then set
> to null in the interceptor.
>
>
>
> The Problem
>
>
>
> All of this appears to be working as I need, except for the first test case.
> In this instance, process() always reports that the discovery data is null,
> even though I am always setting the discovery data into the interceptor
> before invoking the service bus message send.
>
>
>
> My suspicion is that I am over-running a prior test case that hasn’t been
> received and processed “soon enough” before the next test case comes along
> and clobbers it. I need some way to have my injector logic wait until Camel
> intercepts the data of the prior test case, processes it and forwards it on
> to the target.
>
>
>
> I’m looking for suggestions on how I might go about that. I don’t know
> enough about Camel to know what (if any) mechanisms are available that could
> help.
>
>
>
> Thanks,
>
> Joe Gagnon



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2