我在Camel的路径中使用日期:
fileName=${date:now:dd-MM-yyyy}
Run Code Online (Sandbox Code Playgroud)
但我现在需要的是 - 1天.那可能吗?
我需要扩展名最简单的过滤器:fe文件20120523.173227.CustomerMaster05092012.QWERTY.xml route:
<from uri="file://{{fdr.folder.working.url}}&include=*.xml"/>
Run Code Online (Sandbox Code Playgroud)
不起作用:
在索引0附近悬挂元字符'*'
WARN - file://root_folder/working/) [FileConsumer] Consumer Consumer[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed] failed polling endpoint: Endpoint[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed]. Will try again at next poll. Caused by: [java.util.regex.PatternSyntaxException - Dangling meta character '*' near index 0
*.xml
^]
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*.xml
^
at java.util.regex.Pattern.error(Pattern.java:1713)
at java.util.regex.Pattern.sequence(Pattern.java:1878)
at java.util.regex.Pattern.expr(Pattern.java:1752)
at java.util.regex.Pattern.compile(Pattern.java:1460)
at java.util.regex.Pattern.<init>(Pattern.java:1133)
at java.util.regex.Pattern.compile(Pattern.java:823)
at java.util.regex.Pattern.matches(Pattern.java:928)
at java.lang.String.matches(String.java:2090)
at org.apache.camel.component.file.GenericFileConsumer.isMatched(GenericFileConsumer.java:458)
at org.apache.camel.component.file.GenericFileConsumer.isValidFile(GenericFileConsumer.java:395)
at org.apache.camel.component.file.FileConsumer.pollDirectory(FileConsumer.java:94)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at …Run Code Online (Sandbox Code Playgroud) Camel in Action书中的生产者和消费者的定义对我来说有点混乱.我已经读过类似问题的其他两个答案,但我仍然觉得不是那样的.
生产者是Camel抽象,它指的是能够创建消息并将消息发送到端点的实体.图1.10说明了生产者适应其他Camel概念的位置.当需要将消息发送到端点时,生产者将创建交换并使用与该特定端点兼容的数据填充它.例如,a
FileProducer会将消息正文写入文件.甲JmsProducer,在另一方面,将映射骆驼消息到javax.jms.Message其发送到JMS目的地之前.这是Camel的一个重要特性,因为它隐藏了与特定传输交互的复杂性.使用者是接收生产者生成的消息的服务,将它们包装在交换中,然后发送它们进行处理.消费者是在Camel中路由交换的来源.回顾图1.10,我们可以看到消费者与其他Camel概念的契合程度.要创建新的交换,消费者将使用包装正在使用的有效负载的端点.然后使用处理器使用路由引擎启动Camel中的交换路由.
谁在实际创建交易所?典型的沟通渠道的哪一方是生产者和消费者?从上面的文字我不能真正说出谁对此负责.如果有人可以提供一张照片(书中的那张照片对我来说还不清楚),那将是很棒的,其中究竟是生产者和消费者,并解释他们如何以简单的方式工作.也许一些例子也会有用.
好吧也许最好举一个例子,有人可以告诉我它是如何工作的.想象一下,我们想要从文件夹中获取文件并将它们放在JMS队列中,然后从那里发送它们以进行进一步处理,最终保存在磁盘上.
根据我的照片,生产者,消费者到底在哪里?我意识到什么是组件和端点.
我想获得以下类型的路由:
- >此时,我想检查来自外部端点的回复是否是包含等于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导致连接发生刷新网页的队列,从而解除了我遇到的一些线程问题.我该怎么调试呢?
谢谢
我们对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) 我希望有
_ 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的限制?
这似乎应该很简单,原谅双关语.我正试图在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中我可以配置杰克逊的行为?最后一种方法是编写自定义类型转换器.