0

我正在创建一条短信并将其放入 activemq 队列中,然后将其显示在日志中。现在我需要将此消息传递给 cxf rs 客户端以在参数中使用它。我正在使用蓝图来定义骆驼路线和 cxf 客户端。

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
default-activation="eager" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 
         http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint/cxf 
         http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
         http://cxf.apache.org/blueprint/jaxrs 
         http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
         http://cxf.apache.org/configuration/security
         http://cxf.apache.org/schemas/configuration/security.xsd
         http://cxf.apache.org/transports/http/configuration
         http://cxf.apache.org/schemas/configuration/http-conf.xsd">

 <!-- Beans -->

<bean id="myTransform" class="cxfcamel.MyTransform"/>
<bean id="serviceBean" class="cxfcamel.GreetingService" />
<bean id="rsprocessor" class="cxfcamel.RSProcessor"/>



<!-- Web Services -->
<jaxrs:server id="customerService" address="http://localhost:7171  /customers">
    <jaxrs:serviceBeans>
        <ref component-id="serviceBean" />
    </jaxrs:serviceBeans>
</jaxrs:server>

<cxf:rsClient id="rsClient"
    address="http://localhost:7171/customers/entry-point/register/nosJ"
    serviceClass="cxfcamel.GreetingService">
</cxf:rsClient>


<!-- Camel Routes -->
<camelContext id="camel"
    xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="timer://projectTimer?repeatCount=1" />
        <bean ref="myTransform" method="transform" />
        <to uri="activemq:queue:LOG.ME" />
    </route>
    <route>
        <from uri="activemq:queue:LOG.ME" />
        <to uri="log:ExampleActiveMQRouterBlueprint" />
    </route>

    <route>
        <from uri="activemq:queue:LOG.ME" />
        <setHeader headerName="Content-Type">
            <constant>application/json</constant>
        </setHeader>
        <setHeader headerName="CamelHttpMethod">
            <constant>PUT</constant>
        </setHeader>
        <to uri="cxfrs:bean:rsClient" />
    </route>
</camelContext>

任何人都可以帮助我吗?谢谢

4

1 回答 1

0

两条路由都监听activemq:queue:LOG.ME。ActiveMQ 中的一个队列将消费该消息,而任何其他队列都不会接收该消息。你需要做两件事中的一件:

  1. 将您的队列变成一个主题,以便两条路由都能收到消息。主题与队列
  2. 安排您的路线,以便只有一条路线正在收听activemq:queue:LOG.ME

有两种方法可以做到这一点:

  1. 将您的 cxfrs:bean:rsClient 调用转换为 cxfrs: http://localhost:7171/customers/entry-point/register/nosJ并在末尾附加参数。

  2. 这方面的文档不是很清楚,但您也许可以使用 setHeader:

    <setHeader headerName="CamelCxfRsQueryMap"> expression which returns a map </setHeader>

此表达式可以是<bean><groovy>嵌入式表达式等。

于 2015-03-29T06:08:45.983 回答