camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alapaka <alap...@rocketmail.com>
Subject concurrentConsumers, failIfNoConsumers confusion
Date Fri, 24 Mar 2017 04:20:25 GMT
Hi All;

I am trying to implement a route that can process only one message at a
time; the route should reject incoming messages if it is busy. To be clear,
I do not want messages to be queued for processing, I want them to be
rejected and discarded, preferably with an exception returned to the caller.

It would seem that some combination of options on a seda endpoint should do
the trick, however I am not able to achieve this functionality.

Here is my test code, running on camel 2.16.3 in ServiceMix 6.1.2:

from("seda:test-server?concurrentConsumers=1&failIfNoConsumers=true&multipleConsumers=false")
	.log("test server - got request...")
	.delay(15000)
	.log("test server - sending reply")
.routeId("test-server");

from("direct-vm:test-client")
	.log("test client calling server")

.to("seda:test-server?concurrentConsumers=1&failIfNoConsumers=true&multipleConsumers=false")
	.log("test client got reply")
.routeId("test-client");

output from calling the "test-client" route 7 times in less than 10 seconds:

2017-03-24 15:09:03,756 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:03,757 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:03,757 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:09:04,392 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:04,393 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:05,073 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:05,074 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:07,997 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:07,998 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:11,228 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:11,229 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:11,923 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:11,924 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:12,552 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client calling server
2017-03-24 15:09:12,552 | 126 - org.apache.camel.camel-core - 2.16.3 | test
client got reply
2017-03-24 15:09:18,760 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:09:18,761 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:09:33,762 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:09:33,763 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:09:48,765 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:09:48,766 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:10:03,767 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:10:03,768 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:10:18,770 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:10:18,771 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:10:33,772 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply
2017-03-24 15:10:33,773 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - got request...
2017-03-24 15:10:48,775 | 126 - org.apache.camel.camel-core - 2.16.3 | test
server - sending reply

I have tried just about every combination of options on both server and
client, yet no joy.
I know there are other ways to implement this e.g. activemq, database lock,
thread pool? etc... however I would rather a cleaner solution, handled
simply at the incoming endpoint - if that is indeed possible.







--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-failIfNoConsumers-confusion-tp5796061.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message