首页 文章

在Camel路线内重新编组protobuf

提问于
浏览
0

我希望有人可以解释一下如何配置Camel来编组和解组数据 . 我有一个调用bean的路由,以确定一个recipientList . 这是基于消息的内容(protobuf) .

路线配置如下: -

<route id="Splitter">
        <from uri="activemq:notification.splitter" />
        <unmarshal ref="notificationProto" />
        <recipientList>
            <method bean="NotificationSplitter" method="splitNotification" />
        </recipientList>
    </route>

beans 子工作正常,但下游路线抱怨: -

org.apache.camel.RuntimeCamelException: java.lang.RuntimeException: Unable to find proto buffer class

下游路由具有与上述路由完全相同的protobuf dataFormat配置 . 如果我直接路由到下游队列(即绕过bean并硬编码“to”队列),这意味着我也可以跳过解组步骤,它工作正常 .

我想我需要在Camel将消息放入目标队列之前重新封送数据,但我不知道如何在XML中配置它 . 我试过简单地添加......

<marshal ref="notificationProto" />

...在确定了recipientList之后但它没有这样做(我假设因为Camel已经在那时调度了消息) .

另一种方法是从bean内部进行解组,因为交换机上的数据可能会保持不变 . 我不太清楚如何做到这一点 . 会有用吗?

谢谢你的任何提示 .

J.

1 回答

  • 0

    是的,数据格式不是易于发送消息的 endpoints ,否则您可以使用路由滑动EIP模式,并首先将消息发送到数据格式,然后发送到目标 . http://camel.apache.org/routing-slip.html

    虽然你可以有一点路线

    <route>
      <from uri="direct:marshalMe"/>
      <marshal ref="notificationProto" />
    </route>
    

    然后使用路由单,设置为“direct:marshalMe,whereYouWannaGoNext” .

    另一种方法是使用拦截器,并拦截发送到 endpoints (您可以通过通配符或reg exps过滤),然后首先执行编组 . http://camel.apache.org/intercept有关更多详细信息,请参阅该链接 .

相关问题