【问题标题】:Implementing Durable Subscription on ServiceMix在 ServiceMix 上实现持久订阅
【发布时间】:2018-09-29 08:14:20
【问题描述】:

我目前正在使用 ServiceMix 使用 QPID 库来路由消息。

我的工作配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
      http://www.osgi.org/xmlns/blueprint/v1.0.0
      http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

  <bean id="amqp" class="org.apache.camel.component.amqp.AMQPComponent">
    <property name="connectionFactory">
       <bean class="org.apache.qpid.jms.JmsConnectionFactory">
         <property name="remoteURI" value="failover:amqps://remote-broker:9551?transport.trustStoreLocation=/vault/QA_UM_A.jks />

       </bean>
    </property>
  </bean>

  <bean id="kubeActivemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://10.100.10.13:61616" />
  </bean>

  <route>
   <from uri="amqp:queue:///queue-1" />
   <to uri="kubeActivemq:local-queue?jmsMessageType=Text" />
  </route>

  </camelContext>
</blueprint>

上述配置有效。

现在我需要实现持久订阅,这样如果 servicemix 宕机,它能够在它恢复时恢复所有消息(当 servicemix 宕机时发送的消息。)

基于documentation,我实现了一个路由:

<route>
      <from uri="amqp:queue:///queue-1?clientId=1&amp;durableSubscriptionName=bar1" />
      <to uri="kubeActivemq:queue:///local-queue" />
</route>

但是这个实现给出了错误:

2018-05-28 13:28:58,421 | ERROR | mix-7.0.0/deploy | BlueprintCamelContext            | 40 - org.apache.camel.camel-blueprint - 2.16.4 | Error occurred during starting Camel: CamelContext(camel-1) due A durable subscription requires a topic (pub-sub domain)
java.lang.IllegalArgumentException: A durable subscription requires a topic (pub-sub domain)
    at org.springframework.jms.listener.AbstractMessageListenerContainer.validateConfiguration(AbstractMessageListenerContainer.java:435)
    at org.springframework.jms.listener.AbstractJmsListeningContainer.afterPropertiesSet(AbstractJmsListeningContainer.java:157)
    at org.apache.camel.component.jms.JmsConsumer.prepareAndStartListenerContainer(JmsConsumer.java:163)
    at org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:155)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3234)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3528)
    at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3464)
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3394)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3162)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3018)
.
.
.

我在这里错过了什么吗?主题名称不应该与队列名称相同吗?

【问题讨论】:

    标签: apache-camel apache-servicemix qpid durable-subscription


    【解决方案1】:

    您的路线正在指示 Camel 连接到队列,您需要将其更改为使用“主题”来进行持久订阅。 (队列订阅默认是持久的)

    amqp:queue:///queue-1...

    持久订阅需要一个主题

    amqp:topic:///topic-1...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-14
      • 2013-12-17
      • 1970-01-01
      • 2015-08-24
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多