【问题标题】:Broadcast messages using JMSComponent使用 JMSComponent 广播消息
【发布时间】:2015-08-02 17:26:54
【问题描述】:

我有一个问题,我必须将消息广播到不同的输出位置。我正在使用 JMSComponent 来配置我的输出队列。我的输出队列配置是这样的:

ConnectionFactory factory = createOrGetConnectionFactory(brokerUrl);
JmsConfiguration jmsConfiguration = new JmsConfiguration();
jmsConfiguration.setPreserveMessageQos(true);
jmsConfiguration.setConnectionFactory(factory);

counter++;
outputLocations = new StringBuilder("hubOutput"+counter+":queue://queueName");
JmsEndpoint endpoint = new JmsEndpoint();
JmsComponent component = new JmsComponent();
component.setConcurrentConsumers(5);
component.setConfiguration(jmsConfiguration);
component.setConnectionFactory(factory);

//Add new JMS component in the context. This is done so that the output locations having same queue can be differentiated using the component name in camel registry.                       getContext().addComponent("hubOutput"+counter, component);
endpoint = (JmsEndpoint) component.createEndpoint(outputLocations.toString());
endpoint.setConfiguration(jmsConfiguration);

我有一条骆驼路线,用于将消息广播到输出队列。

from(fromLocation)
    .setHeader("hubRoutesList",constant(hubUrl))
    .log(urlToLog)
    .setExchangePattern(ExchangePattern.InOnly)
    .multicast()
    .parallelProcessing()
    .to(hubUrl.split(","));

所有输出队列都有不同的代理 URL,但队列名称相同。 代码正常工作,但如果其中一个队列关闭,则消息也不会广播到其他队列。

请帮我解决这个问题。

谢谢, 里查

【问题讨论】:

    标签: queue jms apache-camel


    【解决方案1】:

    您可以使用收件人列表代替 .to(hubUrl.split(","));

    使用选项 stopOnException=false(默认值)时,即使您的一个队列已关闭,将消息转发到其他端点也不会停止。 请参阅http://camel.apache.org/recipient-list.html 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2018-04-02
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-24
      相关资源
      最近更新 更多