On Thu, Feb 4, 2016 at 6:13 PM, jnk <[email protected]> wrote: > We are using camel-sjms 2.15.2 but it can be reproduced with 2.16.2, too. >
Okay sounds like the suspend opertation on the consumer does not stop the jms listener. You are welcome to log a JIRA so we get this looked into and fixed. http://camel.apache.org/support.html > > Claus Ibsen-2 wrote >> What version of Camel do you use? >> >> On Thu, Feb 4, 2016 at 11:03 AM, d1x < > >> zdenek.obst@ > >> > wrote: >>> I'm using SJMS (simple JMS) component for consuming messages from JMS >>> broker >>> (e.g. ActiveMQ). >>> When I'm stopping Camel Context, I'm used to that consumers will stop >>> accepting new messages (in case JMS I would expect consumer will stop >>> reading new messages from broker and will finish only processing ones). >>> But >>> it does not work for SJMS. When I stop camel context with SJMS consumer, >>> it >>> keeps reading messages forever (as long as there are any present in >>> broker >>> queue). >>> >>> Am I misusing the SJMS component or is it a bug? >>> >>> Here is the code I'm using for testing (I pre-fill ActiveMQ queue test >>> with >>> 100 messages for example): >>> >>> public class Test { >>> >>> public static void main(String[] args) throws Exception { >>> RouteBuilder rb = new RouteBuilder() { >>> @Override >>> public void configure() throws Exception { >>> from("sjms:queue:test?consumerCount=5") >>> .process(new Processor() { >>> @Override >>> public void process(Exchange exchange) throws >>> Exception { >>> Thread.sleep(1000); // not to consume all >>> messages instantly >>> System.out.println("Processed message " + >>> exchange.getExchangeId()); >>> } >>> }); >>> } >>> }; >>> >>> CamelContext context = new DefaultCamelContext(); >>> context.getShutdownStrategy().setTimeout(2 * 1000); // 2 seconds >>> is >>> enough for already fetched messages >>> addJmsComponent(context); >>> context.addRoutes(rb); >>> >>> System.out.println("=====> Starting context"); >>> context.start(); >>> Thread.sleep(5 * 1000); // Consume few messages at the beginning >>> >>> System.out.println("=====> Stopping context"); >>> context.stop(); >>> System.out.println("=====> Context stopped"); // Will not get >>> here >>> as long as there are any messages left in the queue >>> } >>> >>> private static void addJmsComponent(CamelContext context) { >>> ConnectionFactory factory = new >>> ActiveMQConnectionFactory("tcp://localhost:61616"); >>> ConnectionFactoryResource connResource = new >>> ConnectionFactoryResource(5, factory); >>> SjmsComponent comp = new SjmsComponent(); >>> comp.setConnectionResource(connResource); >>> context.addComponent("sjms", comp); >>> } >>> } >>> >>> >>> >>> -- >>> View this message in context: >>> http://camel.465427.n5.nabble.com/CamelContext-stop-with-SJMS-consumer-does-not-stop-consuming-messages-from-broker-tp5777207.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> >> -- >> Claus Ibsen >> ----------------- >> http://davsclaus.com @davsclaus >> Camel in Action 2: https://www.manning.com/ibsen2 > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/CamelContext-stop-with-SJMS-consumer-does-not-stop-consuming-messages-from-broker-tp5777207p5777223.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
