简体   繁体   中英

Concurrent consumers of Seda in Apache camel

I have a route as mentioned below. The route polls a directory at regular interval and reads a big size .csv file. It then split the files in chunk of 1000 lines and sends it to the seda queue(firstQueue) . I have 15 concurrent consumers on this seda queue.

route.split().tokenize("\n", 1000).streaming().to("seda:firstQueue?concurrentConsumers=15").process(myProcessor).to("seda:secondQueue?concurrentConsumers=15").process(anotherMyProcessor);

1) What does 15 concurrent consumers means - does it means 15 threads read data from the seda and pass it to one instance of myProcessor ? Or 15 separate instance of myProcessor are created each one acting on the same copy of the data? Note that myProcessor is a singleton, what will happen if I change it to prototype.

2) Is it possible that any two or more threads pick the same data and pass it to the myProcessor ? Or is it guaranteed that no two threads will have the same data ?

Appreciate a quick response. Thanks!

My Camel is a bit rusty but I'm pretty sure that

  1. There are 15 threads running. Each will read a message from the queue and call myProcessor. There is only one instance of my processor so you need to make sure that it is thread safe. I've never tried the it, but I don't believe changing the scope to prototype will make any difference.

  2. Two threads should not pick up the same message from the queue. In normal running each message should get processed just once. However, there are error conditions that my result in the same message being processes twice, the most obvious one being that you restart the app part way through processing the file.

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