首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用amq处理cxf请求

用amq处理cxf请求
EN

Stack Overflow用户
提问于 2018-01-04 04:47:10
回答 1查看 195关注 0票数 0

我想提出这样一个解决办法:

  1. cxf https soap服务获取一个请求并将其发送到activemq队列1。
  2. 服务实现从队列1获取消息,处理它并放入队列2。
  3. 端点从队列2获取响应,并将响应发送给客户端。

现在,我提出了一种解决方案,但我不知道如何处理activemq中的响应并将其作为SOAP响应发送回来。下面是我的骆驼蓝图。端点蓝图:

代码语言:javascript
复制
    <?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"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
           xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
           xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
             http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
             http://cxf.apache.org/blueprint/bindings/soap http://cxf.apache.org/schemas/configuration/blueprint/soap.xsd">
    <bean id="cardServiceEndpoint" class="com.endpoint.card.CardEndpoint">
        <argument>
            <reference interface="com.card.CardService" />
        </argument>
    </bean>
    <cxf:cxfEndpoint
        id="cardEndpoint" 
        address="https://host:port/soa/card"
        serviceClass="com.card.CardService">
        <cxf:properties>
            <entry key="schema-validation-enabled" value="true" />
        </cxf:properties>
    </cxf:cxfEndpoint>
    <bean id="jaxB" class="org.apache.camel.model.dataformat.JaxbDataFormat">
        <property name="prettyPrint" value="true" />
        <property name="contextPath" value="com.type.card" />
    </bean>
    <camelContext id="endpoint-card-cxf" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="endpoint-soap-in">
            <from uri="cxf:bean:cardEndpoint"/>
            <transform>
                <simple>${body[0]}</simple>
            </transform>
            <marshal ref="jaxB"/>
            <setHeader headerName="JMSType">
                <simple>${headers.operationName}</simple>
            </setHeader>
            <to uri="amq:q.in"/>
        </route>
        <route id="endpoint-soap-out">
            <from uri="amq:q.out" />
            <unmarshal ref="jaxB" />
            <!-- STUCK HERE :( -->
        </route>
    </camelContext>
</blueprint>

服务处理器蓝图:

代码语言:javascript
复制
<?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"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    <bean id="cardService" class="com.card.impl.DefaultCardService">
        <argument>
            <reference interface="com.base.StashService"/>
        </argument>
    </bean>
    <service interface="com.card.CardService" ref="cardService" />
    <bean id="amqCardServiceEndpoint" class="com.card.endpoint.AmqCardEndpoint">
        <argument ref="cardService" />
    </bean>
    <bean id="jaxB" class="org.apache.camel.model.dataformat.JaxbDataFormat">
        <property name="prettyPrint" value="true" />
        <property name="contextPath" value="com.type.base:com.type.card" />
    </bean>
    <camelContext id="service-card-cx" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="card-rq-broker">
            <from uri="amq:queue:q.in?asyncConsumer=true" />
            <unmarshal ref="jaxB" />
            <doTry>
                <bean ref="amqCardServiceEndpoint" method="invoke" />
                <doCatch>
                    <exception>com.type.base.BaseException</exception>
                    <setBody>
                        <simple>${exception.getFaultInfo()}</simple>
                    </setBody>
                </doCatch>
            </doTry>
            <marshal ref="jaxB" />
            <to uri="amq:q.out" />
        </route>
    </camelContext>
</blueprint>

有什么帮助或建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-04 08:22:08

使用jmsReplyTo指定Camel用于侦听响应的应答队列的名称(如果您想要一个固定的队列名称)。请参阅有关Camel JMS文档的请求/答复的更多信息。

代码语言:javascript
复制
<to uri="amq:q.in?jmsReplyTo=q.out"/>
// continue here when reply is back
  • http://camel.apache.org/jms
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48088811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档