当前位置: 首页 > 知识库问答 >
问题:

使用 amq 处理 cxf 请求

洪黎昕
2023-03-14

我想做这样的解决方案:

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

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

    <?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>

服务处理器蓝图:

<?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>

有什么帮助或建议吗?

共有1个答案

咸亦
2023-03-14

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

<to uri="amq:q.in?jmsReplyTo=q.out"/>
// continue here when reply is back
  • http://camel.apache.org/jms
 类似资料:
  • 问题内容: 我正在开发一些基于Web服务的应用程序,并且对Apache CXF解组有疑问。在我们的项目中,我们使用CXF 2.4.1版本。 当某些SOAP请求不正确时(例如,某些字段是文本而不是数字),CXF会抛出标准的SOAPFaultException,并且SOAP响应将使用以下标准字段构建: 项目要求说,如果发生任何故障,系统需要以其他格式响应,例如: 所以问题是:如何以某种方式覆盖此错误处

  • 问题内容: 我正在尝试构建一个简单的Golang / Appengine应用程序,该应用程序使用通道来处理每个http请求。原因是我希望每个请求都执行合理的大内存计算,并且以线程安全的方式执行每个请求(即,并发请求的计算不会混淆)非常重要。 本质上,我需要一个同步队列,该队列一次只能处理一个请求,并且通道看起来很自然。 是否可以将Go的缓冲通道用作线程安全队列? 但是,我无法让我简单的hello

  • 目前我正在研究聊天服务器/客户端项目。我正在努力使用 select 处理多个请求,我的服务器脚本使用 select 模块,但客户端脚本没有。结果是,当用户输入消息时,其他客户端必须编写自己的消息才能通读对话。我已经在网上搜索了很多示例,但只能找到带有 sys.stdin 的代码片段,这不是我想要的。 我很高兴收到任何指示/解释。 服务器代码: 客户端代码:

  • 请求处理 fpm_run()执行后将fork出worker进程,worker进程返回main()中继续向下执行,后面的流程就是worker进程不断accept请求,然后执行PHP脚本并返回。整体流程如下: (1)等待请求: worker进程阻塞在fcgi_accept_request()等待请求; (2)解析请求: fastcgi请求到达后被worker接收,然后开始接收并解析请求数据,直到req

  • 我使用ApacheCamel在ActiveMQ和camel HTTPendpoint之间进行路由。路由的定义方式是,将数据从camel cxf webservice传输到ActiveMQ,并将这些数据发送到tomcat,tomcat是一个HTTPendpoint,然后一旦HTTP uri命中,camel就会从tomcat服务器获得响应。 只有在成功路由后,我们才能从骆驼那里确认队列,我的意思是在L