Solution to Camel-HTTP Component Performance Problems
Learn how to solve a problem with the camel-http component preventing concurrent processing and slowing down processing time.
Join the DZone community and get the full member experience.
Join For FreeToday, I'm posting a simple solution to a problem that I was having. Maybe some of you are having this same problem as well.
Context: A camel route that takes 10 exchanges at once from a queue and sends to a webservice.
Problem: Processing time seems too slow and it's not working like I was expecting.
Code:
from("activemq:queue:process1?concurrentConsumers=10")
.to("http://ws.someservice.com/v1/resource");
Reading the code above, we may expect there will be ten threads calling the web service at once, right? But using some logs and running tests, I realized the camel-http
component was creating a sort of internal queue and making only two calls at once, not respecting concurrent processing.
Solution: After a headache, I resolved this problem using the camel-jetty
component at the beginning of the line.
New code:
from("activemq:queue:process1?concurrentConsumers=10")
.to("jetty:http://ws.someservice.com/v1/resource");
Then, rerunning the tests, I saw that the problem was solved! The application was consuming ten exchanges at once and sending them to the web service at the same time.
That's all. I hope this information may be useful to you.
Opinions expressed by DZone contributors are their own.
Comments