小编Hoo*_*tUp的帖子

有人能指出我使用cxfrs客户端/生产者的Camel路由工作示例吗?

我无法让我的Camel路由成功将消息发送到现有的RESTful Web服务.我已经尝试了camel cxf包中的所有示例,但它们都没有产生Web服务调用(它们是消费者).我很乐意为此找到一个有用的示例,因此我可以逐步执行CxfRsProducer执行,以便发现我的路由未正确发布到Web服务的原因.

这是我的RouteBuilder的配置:

public void configure()
{
    //errorHandler(deadLetterChannel(String.format("file:%s/../errors", sourceFolder)).useOriginalMessage().retriesExhaustedLogLevel(LoggingLevel.DEBUG));
    errorHandler(loggingErrorHandler());

    /*
     * JMS to WS route for some of the events broadcast to the jms topic
     */
    Endpoint eventTopic = getContext().getEndpoint(String.format("activemq:topic:%s?clientId=%s&durableSubscriptionName=%s", eventTopicName, durableClientId, durableSubscriptionName));

    from(eventTopic)            // listening on the jms topic
    .process(eventProcessor)    // translate event into a Notifications object (JAX-RS annotated class)
    .choice()                   // gracefully end the route if there is no translator for the event type
    .when(header("hasTranslator").isEqualTo(false)).stop() // no translator stops the route
    .otherwise()                // send the notification …
Run Code Online (Sandbox Code Playgroud)

apache-camel cxfrs

5
推荐指数
1
解决办法
9544
查看次数

使用CXFRS端点和xPath在Camel中使用基于内容的路由时遇到问题

我正在尝试使用xPath创建由REST有效内容中的内容确定的路由.我已成功使用基于邮件头的路由:

<when>
   <simple>${headers.operationName} == 'createContainerOutput'</simple>
   <bean ref="containerOutputProcessor"/>
</when>
Run Code Online (Sandbox Code Playgroud)

正确调用containerOutputProcessor ...

但是对于这个xPath路由:

<when>
    <xpath>/*[local-name()='order-request']/@type='TrayOutput'</xpath>
    <bean ref="containerOutputProcessor"/>
</when>
Run Code Online (Sandbox Code Playgroud)

我得到了例外:

org.apache.camel.NoTypeConversionAvailableException:没有类型转换器可用于将类型:org.apache.cxf.message.MessageContentsList转换为所需类型:org.w3c.dom.Document,其值为[com.mmi.ws.ContainerOutputOrderRequest@6290dc ]

这个有效载荷

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
    <parameter name="orderName">Example Tray Output Order</parameter>
    <parameter name="enableScan">true</parameter>
    <parameter name="autoStart">false</parameter>
    <parameter name="priority">3</parameter>
    <item barcode="23990001"/>
    <item barcode="23990002"/>
</order-request>
Run Code Online (Sandbox Code Playgroud)

这种类型的路由是个好主意吗?是否有更好的方法根据提交的订单请求类型进行路由?

感谢您对我的任何帮助/指导!


这是完整的背景

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
     http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">

  <!-- enable Spring @Component scan -->
  <context:component-scan base-package="com.mmi.ws"/>

    <!--  web service beans …
Run Code Online (Sandbox Code Playgroud)

xpath apache-camel cxfrs

1
推荐指数
1
解决办法
3880
查看次数

标签 统计

apache-camel ×2

cxfrs ×2

xpath ×1