【问题标题】:Apache camel and Jms example programApache骆驼和Jms示例程序
【发布时间】:2014-04-26 23:48:57
【问题描述】:

我正在使用一个程序使用 jms 和 apache camel 将消息发布到 activemq..

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();
    }
}

它正确地放置了 10 条消息...但问题是当将“i”的计数增加到 100,500 或我无法在测试文件夹中找到这么多消息时..帮我解决这个问题.. ..提前谢谢..

【问题讨论】:

    标签: jms apache-camel activemq jms-topic


    【解决方案1】:

    如果您将这么多消息发送到队列,那么您可能需要在线程睡眠中等待更长时间,然后才能停止 Camel 和应用程序。

    例如,您需要给它更多时间来处理队列中的所有消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 2012-11-10
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多