1
votes

I am not sure how many people have had a chance to deal with Camel Processors. So this is my concern:

I am obtaining some information and sending it to the processor. From the processor, it makes a database call via service and inserts a record. I am using a POJO and setting the values in my model in the processor via the exchange object. I am not at all facing any issues but processor is not meant for setting values in a list or any other structure. It should simply do some processing over the exchange object and pass it on primarily due to the fact that there might be a situation where multiple threads could call the same processor.

This is what I would like to know:

  1. Is there any other alternative to processors in Camel where I can do this kind setting over the model. Ex: wiretapping, interceptor etc.
  2. If not what else could be the approach?
1
This sentence is incorrect: It should simply do some processing over the exchange object and pass it on primarily due to the fact that there might be a situation where multiple threads could call the same processor. Where did you get this information from? - Namphibian
I am not sure on your question. But you can create a bean and call a method in that bean and that method can perform that db call you want to . - Naveen Raj

1 Answers

3
votes

Processors are singletons and therefore shouldn't be used to store state of any type...

some options...

  • store state information in the Exchange properties or Body headers

  • replace a Processor with a Bean where you can manage the scope (prototype, etc)

  • use ThreadLocal variables for non thread safe references