Osgi 如何将消息从activemq队列传递到cxf客户端rest

Osgi 如何将消息从activemq队列传递到cxf客户端rest,osgi,apache-camel,cxf,activemq,blueprint,Osgi,Apache Camel,Cxf,Activemq,Blueprint,我正在创建一条文本消息并将其放入activemq队列中,然后将其显示在日志中。现在,我需要将此消息传递给cxf rs客户端,以便在参数中使用它。我正在使用blueprint定义驼峰路由和cxf客户端 <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="eager" xmlns:xsi="ht

我正在创建一条文本消息并将其放入activemq队列中,然后将其显示在日志中。现在,我需要将此消息传递给cxf rs客户端,以便在参数中使用它。我正在使用blueprint定义驼峰路由和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>
有人能帮我吗? 谢谢

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

将队列转换为主题,以便两条路由都能接收消息。 安排您的路由,以便只有一个路由正在侦听activemq:queue:LOG.ME。 有两种方法可以实现这一点:

将您的cxfrs:bean:rsClient调用转换为cxfrs:,并在末尾追加参数

关于这方面的文档不是很清楚,但您可以使用setHeader:

返回映射的表达式


此表达式可以是嵌入表达式等。

感谢您的响应,但我想将队列消息传递到CXF RS客户端中的URL,以便将其用作查询参数。例如:{queue message}您能帮我一下吗!!可以这更有道理。我会更新我的答案。我在您的原始帖子中没有看到这些信息,但我现在看到了=在我的案例中,我在cxfrs端点中有一个基本的身份验证,如下所示:我认为第一个方案对我的案例不起作用!!虽然我没有第二条路!!我应该声明一个包含映射的bean还是什么!!