0

我对骆驼的溃败遇到了一些问题。这是我的配置文件,很简单:

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

<camel:camelContext xmlns="http://camel.apache.org/schema/spring">

    <jmxAgent id="agent" createConnector="false" disabled="true"/>

    <camel:route>
        <route>
            <from uri="activemq:hello?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/>
            <to uri="stream:out"/>
        </route>
    </camel:route>
</camel:camelContext>

在这种情况下,我使用的是 RabbitMQ,hello 是队列名称。

运行它,我收到以下错误消息:

Invocation of init method failed; nested exception is java.lang.IllegalArgumentException:  Route has no inputs: Route[[] -> [Route[[From[activemq:hello?destination.consumer.exclusive=true&destination.consumer.prefetchSize=50]] -> [To[stream:out]]]]]

任何想法?我在哪里可以获得 Camel + RabbitMQ 的示例或教程?

- - 更新 - -

按照以下评论的建议,我修复了配置,并且已经完成了一小步。现在它似乎能够连接到队列但是,如果我尝试写我得到“camelContext must be specified”异常

<bean id="messageConverter" class="amqp.spring.converter.XStreamConverter"/>

<rabbit:connection-factory id="connectionFactory" host="10.211.55.20" port="5672" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" message-converter="messageConverter" exchange="amq.fanout" />
<rabbit:admin connection-factory="connectionFactory"/>
<rabbit:queue name="hello"  />

<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
    <camel:route>
        <camel:from uri="file:src/data?noop=true" />
        <camel:log message="Log!"/>
        <camel:to uri="spring-amqp:amq.fanout:hello"/>
    </camel:route>
</camel:camelContext>

谢谢,
安德里亚

4

2 回答 2

0

有两个错误。首先,XML 似乎在路由上缺少命名空间:

<camel:route>
   <route>
        <from uri="activemq:hello?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/>
        <to uri="stream:out"/>
    </route>

应该:

<camel:route>
   <camel:route>
        <camel:from uri="activemq:hello?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/>
        <camel:to uri="stream:out"/>
    </camel:route>

那么,目前 RabbitMQ 与 ActiveMQ 并不真正兼容。ActiveMQ 5.8 版似乎支持 RabbitMQ 使用的 AMQP 协议,但是否会在 Camel 组件中支持或是否与 RabbitMQ 兼容是另一个问题。我不知道。

Camel 中也有一个 AMQP 组件。它使用的是 Apache QPID 客户端,我没有任何运气使用 RabbitMQ 运行它。如果您深入研究使用某些特定版本等(http://www.rabbitmq.com/interoperability.html),它可能会在某种程度上起作用。

于 2013-01-08T07:18:13.250 回答
0

我遇到过同样的问题。原来我把routes叠起来了。所以,而不是拥有

<camel:route>
   <route>
        <from uri="activemq:hello?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/>
        <to uri="stream:out"/>
    </route>

只需跳过封闭的<route>.

于 2017-12-13T14:25:59.787 回答