0

I am using one program to publish messages to activemq using jms and apache camel..

public final class CamelJmsTofileExample {

    private CamelJmsTofileExample() {}

    public static void main(String args[]) throws Exception {
        CamelContext context = new DefaultCamelContext();
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://localhost?broker.persistent=false");
        context.addComponent("test-jms",
            JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("test-jms:queue:test.queue").to("file://test");
            }
        });
        ProducerTemplate template = context.createProducerTemplate();
        context.start();
        for (int i = 0; i < 100; i++) {
            template.sendBody("test-jms:queue:test.queue", "Test Message: " + i);
        }
        Thread.sleep(1000);
        context.stop();
    }
}

It is putting 10 message correctly...But the problem is when increasing the count of "i" to 100,500 or something i am not able to find that many messages in test folder..Help me in resolving this problem....Thanks in advance..

Peter Keller
  • 7,526
  • 2
  • 26
  • 29
Rahul
  • 149
  • 4
  • 11

1 Answers1

0

If you send so many messages to a queue, then you likely need to wait longer in your thread sleep before you stop Camel and the application.

eg you need to give it more time to process all the messages on the queue.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65