camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zdeněk Obst (JIRA) <>
Subject [jira] [Created] (CAMEL-9567) Consumer does not suspend (on context) stop
Date Fri, 05 Feb 2016 07:21:39 GMT
Zdeněk Obst created CAMEL-9567:

             Summary: Consumer does not suspend (on context) stop
                 Key: CAMEL-9567
             Project: Camel
          Issue Type: Bug
          Components: camel-sjms
    Affects Versions: 2.16.2
            Reporter: Zdeněk Obst

When using SjmsConsumer that consumes JMS messages from broker (e.g. ActiveMQ) and *stop Camel
Context, the consumer still reads new messages from broker* even if it should only finish
processing of already fetched messages. It causes that Context is never stopped if there are
still new and new messages in the broker (or before timeout for stop operation occurs).

When I investigated code, it seems that suspend operation is not implemented (or code does
not check isSuspended flag). What I would expect is that consumer unregisters listener on
context stop (consumer suspend).

Here is the sample code I used for testing:
public class Test {

    public static void main(String[] args) throws Exception {
        RouteBuilder rb = new RouteBuilder() {
            public void configure() throws Exception {
                        .process(new Processor() {
                            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); // 2 seconds is enough for already fetched

        System.out.println("=====> Starting context");
        Thread.sleep(5 * 1000); // Consume few messages at the beginning

        System.out.println("=====> Stopping context");
        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();
        context.addComponent("sjms", comp);

The original mailing list thread:

This message was sent by Atlassian JIRA

View raw message