我想获得以下类型的路由:
- >此时,我想检查来自外部端点的回复是否是包含等于SUCCESS的XML参数的HTTP 200 OK. - >如果是的话,那么我想使用一些存储的参数来构造一个新的HTTP消息(此次方法= PUT)并将其发送到外部端点
我目前遇到的问题如下:
.choice()
.when(simple("${in.headers.CamelHttpResponseCode} == 200"))
// now I want do a few things, eg: check also the XML body via xpath
// and change the message to be sent out (change Method to PUT, ...)
.to("http://myserver.com")
.otherwise()
// if no 200 OK, I want the route to be stopped ... not sure how ?
.end()
Run Code Online (Sandbox Code Playgroud)
问题:如果HTTP响应代码是200 OK,任何想法如何添加这些额外的语句?看起来什么时候不允许我添加额外的语句...(我在Eclipse IDE中出错).
提前致谢.
注意:如果200 OK与"新端点"匹配,然后使用此新端点创建新的路由,我是否必须路由消息?例如:
.choice()
.when(simple("${in.headers.CamelHttpResponseCode} == 200"))
.to("mynewendpoint")
.otherwise() …Run Code Online (Sandbox Code Playgroud) 我有一个使用SSL传输的activeMQ代理.我有大约10个使用经纪人的消费者.我正在使用camel来配置我的路由.
即使我重新启动了消费者,即使队列中有待处理的消息,它也会经常挂起并且不会消耗新消息.
我开始尝试通过一次尝试复制问题来逐步通过我的消费者来隔离发生这种情况的地方.我终于找到了一个可以重新创建问题的消费者.它会在一段时间后挂起,但是,如果我转到活动的MQ管理控制台并尝试查看队列中的消息,它将再次开始运行.我认为Jetty导致连接发生刷新网页的队列,从而解除了我遇到的一些线程问题.我该怎么调试呢?
谢谢
在像Apache Camel这样的ESB上,什么机制实际上是沿着从端点到端点的路由"前进"(拉/推)消息?
请问骆驼RouteBuilder刚刚组成的图形Endpoints和Routes以及知道哪些目的地/下一Endpoint传递一个消息给它访问某后Endpoint还是做Endpoints自己知道这是因为它已经处理了消息的下一个目的地.
无论哪种方式,我都很困惑:
RouteBuilder知道通过系统的消息"流",那么这RouteBuilder需要知道何时Endpoint A应该将消息传递给Endpoint Bvs 旁边的业务逻辑Endpoint C,但是在所有Camel示例中我看到这个业务逻辑没有存在; 和Endpoints一起将它们组合在一起并破坏了SOA/ESB/EIP等的一些基本原则.我们对AMQ使用以下配置
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${brokerURL1}"/>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="10"/>
<property name="maximumActive" value="100"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="5"/>
<property name="maxConcurrentConsumers" value="10"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我经常有一个奇怪的问题 - 松散的信息.实际上AMQ表示一切正常并且消息已经出列但是应用程序上没有消息...
我已经读过它可能是缓存消费者的问题,而应该在配置后使用JmsConfiguration
<bean id="jmsConfig" class="org.apache.activemq.camel.component.ActiveMQConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="concurrentConsumers" value="5"/>
<property name="maxConcurrentConsumers" value="10"/>
<property name="cacheLevelName" value="CACHE_CONSUMER"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何正确配置activemq?哪些值应设置为最佳性能和良好的可靠性?
<property name="maxConnections" value="?"/>
<property name="maximumActive" value="?"/>
<property name="concurrentConsumers" value="?"/>
<property name="maxConcurrentConsumers" value="?"/> …Run Code Online (Sandbox Code Playgroud) 我有一项服务,有两个操作.
RegisterUser
UpdateUser
Run Code Online (Sandbox Code Playgroud)
我有一个骆驼溃败:
<camel:route id="myRoute">
<camel:from uri="cxf:bean:myListenerEndpoint?dataFormat=POJO&synchronous=true" />
<camel:bean ref="processor" method="processMessage"/>
<camel:to uri="xslt:file:resources/service/2.0.0/UserRegistration.xsl"/>
<camel:to uri="cxf:bean:myTargetEndpoint"/>
</camel:route>
Run Code Online (Sandbox Code Playgroud)
在我的处理器bean中,当我指定:
RegisterUser registerUser = exchange.getIn().getBody(RegisterUser.class);
Run Code Online (Sandbox Code Playgroud)
我得到了注册用户对象.一切正常.问题是我希望camel有条件地路由我的请求,例如:
如果服务操作是RegisterUser我想将消息路由到我的特定bean,如果服务操作是UpdateUser我想将消息路由到另一个bean.
我曾尝试使用camel xPath,但它似乎没有用.
<camel:route id="myRoute">
<camel:from uri="cxf:bean:myListenerEndpoint?dataFormat=POJO&synchronous=true" />
<camel:choice>
<camel:when>
<camel:xpath>
//RegisterUser
</camel:xpath>
<camel:bean ref="processor" method="processMessage"/>
<camel:to uri="xslt:file:resources/service/2.0.0/UserRegistration.xsl"/>
</camel:when>
</camel:choice>
<camel:to uri="cxf:bean:myTargetEndpoint"/>
</camel:route>
Run Code Online (Sandbox Code Playgroud)
我正在寻找如何设置骆驼路线到不同的目标,但没有找到任何东西.也许有人知道问题出在哪里?
我希望有
_ from( A )
_ .split()...
_ .choice() //Choice 1
_ .when( predicate )
_ .process()
_ .choice() // Choice 2
_ .when( x )
_ .to( X )
_ .otherwise()
_ .to( Y )
_ .end() // to terminate inner choice
_ .endchoice() // tell camel we're back in the outer-choice - gets exception
_ .otherwise() // Choice 1
_ .to( Z )
_ .end()
Run Code Online (Sandbox Code Playgroud)
但我在endChoice()上得到运行时异常
java.lang.ClassCastException: org.apache.camel.model.SplitDefinition cannot be cast to org.apache.camel.model.ChoiceDefinition
Run Code Online (Sandbox Code Playgroud)
没有它我得到编译时错误
我怀疑end()结束了内在和外在的选择,我只希望它结束内在的选择.
没有放入end()使得它将第二个()视为内部选择的扩展.它不是.
我已经找到了解决方法,将第二个选项放在子路径中并将"direct:SUB_ROUTE"放入其中,但如果可以的话,我更愿意使用上面概述的平面结构.有没有办法在选择中实现选择,还是只是Java DSL的限制?
有什么区别:
<camel:errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel"
deadLetterUri="log:dead">
<camel:camelContext errorHandlerRef="deadLetterErrorHandler">
...
</camel:camelContext>
Run Code Online (Sandbox Code Playgroud)
和:
<onException>
...
</onException>
Run Code Online (Sandbox Code Playgroud)
根据这篇文章,将它们结合使用是一种"强大的组合".怎么会这样?他们每个人扮演什么角色,他们如何相互补充?
这似乎应该很简单,原谅双关语.我正试图在Spring DSL路线中记录骆驼的标题.我已经看到了Java DSL的答案,但我一直在寻找如何使它在Spring DSL中工作的徒劳.我试过了:
<log message="ftping $simple{header.CamelFileName}"/>
Run Code Online (Sandbox Code Playgroud)
并且:
<log message="ftping ${header.CamelFileName}"/>
Run Code Online (Sandbox Code Playgroud)
和其他几个排列/变体,但所有这些只是简单地记录该文本(即它们不替代实际的标题名称).
我错过了什么?
更新:这是我的xml文件的更大部分:
<split>
<simple>${body}</simple>
<setHeader headerName="CamelFileName">
<simple>${body.batchNumber}.xml</simple>
</setHeader>
<log message="SLH - 5 -- marshalling an EFileBatch to XML" loggingLevel="DEBUG" />
<marshal>
<jaxb prettyPrint="true" contextPath="generated.gov.nmcourts.ecitation"
partClass="generated.gov.nmcourts.ecitation.NMCitationEFileBatch"
partNamespace="EFileBatch" />
</marshal>
<log message="SLH - 6 -- xslt transform to add schema location" loggingLevel="DEBUG" />
<to uri="{{addSchemaLocationXsltUri}}"/>
<log message="SLH - 7 -- ftp now initiating" loggingLevel="DEBUG" />
<log message="ftping ${headers.CamelFileName}"/>
<to uri="{{ftpOdysseyInputPath}}"/>
<log message="SLH - 8 -- ftp now …Run Code Online (Sandbox Code Playgroud) 我正在使用Apache Camel 2.13.1和MongoDB 2.2.2.我有以下路线:
<route id="camel-route" autoStartup="true">
<from uri="file:/dir?move=${date:now:yyyyMMdd}\processed\${file:name}&moveFailed=${date:now:yyyyMMdd}\failed\${file:name}" />
<unmarshal>
<jaxb prettyPrint="false" contextPath="com.example.model" />
</unmarshal>
<to uri="mongodb:connectionBean?database=db&collection=coll&operation=save" />
</route>
Run Code Online (Sandbox Code Playgroud)
文件使用者端点获取XML文件并将其解组为POJO,该POJO包含数据类型为int,String和java.util.Date的多个字段.它保存/插入正常但日期字段保存为NumberLong类型,而不是类型ISODate.
但是如果我使用MongoDB Java驱动程序保存它(即创建DBObject,使用字段"new Date()"映射一个键),它将在MongoDB中保存为ISODate.我可以通过使用camel XML DSL来实现这一点吗?
编辑:深入研究代码和文档,camel-mongodb使用Jackson,首先将其转换为Map,然后转换为BasicDBObject.有没有办法在XML DSL中我可以配置杰克逊的行为?最后一种方法是编写自定义类型转换器.
apache-camel ×10
java ×7
apache-karaf ×1
architecture ×1
cxf ×1
date ×1
esb ×1
isodate ×1
mongodb ×1
routing ×1
soa ×1