I want old messages to be automatically removed from topic so I'm using the option timeToLive which is described in the Camel ActiveMQ component documentation. However, it only works with queue and not with topic. Any idea why?
For testing purposes I made this simple route:
<route>
<from uri="timer://foo?repeatCount=1"/>
<to uri="activemq:topic:test?timeToLive=10000"/>
</route>
Route sends message to my test topic with TTL=10seconds. I would expect that after 10 seconds message would disappear.
When I use queue instead everything works as expected ( <to uri="activemq:queue:test?timeToLive=10000"/> )
Related
There is a route which is consuming messages from a jms queue and after doing some processing sending a request to unreliable web service(Which can be down at times).
So in case of service is down then i need to stop consuming from queue for some time. I tried to use ThrottlingExceptionRoutePolicy . It will stop route as per configuration but issue is for the current message which gets the error as message is getting moved to dead letter queue. I've gone through the code of ThrottlingExceptionRoutePolicy as per code this will be called after all error handling is done for route.
So i need to modify default error handling of camel to avoid putting message to DLQ for some specific cases. I tried to configure various error handlers provided by camel but in all cases camel is putting messages to DLQ.
Is there some configuration or i need to write custom error handler to achieve the same.
<camel:route id="someroute" routePolicyRef="throttlingExceptionRoutePolicy"
errorHandlerRef="myTransactionErrorHandlerErrorHandler">
<camel:from uri="activemq:inputQueue" />
<camel:transacted />
<camel:bean ref="afterQueueProcessor" />
<camel:setHeader headerName="CamelHttpMethod">
<camel:constant>POST</camel:constant>
</camel:setHeader>
<camel:setHeader headerName="Content-Type">
<camel:constant>application/xyz</camel:constant>
</camel:setHeader>
<camel:to
uri="http://localhost:8080/some-ws/newOrder?orderId=dd&productName=bb&quantity=1" />
</camel:route>
This questions is related to async communication
My Camel:
<from uri="quartz2://processTimers?cron=5+*+*+*+*+*" />
<to uri="mybatis:selectProducts?statementType=SelectList&onConsume=consumeProduct"/>
<bean ref="productService" method="process" />
<to uri="mq:queue:my.queue"/>
When using a Quartz from, the selectProducts returns the expected results but the onConsume for some doesnt execute at the end, I suspect this is because its a "to" and not a "from" method.
Is there anyway to have a cron scheduled mybatis select with an onConsume?
Updated:
<from uri="mybatis:selectProducts?statementType=SelectList&onConsume=markProductAsExtracted&maxMessagesPerPoll={{MAX_RECORDS_PER_PROCESS}}&scheduler=quartz2&scheduler.cron=5+*+*+*+*+?"/>
<bean ref="productService" method="process" />
<to uri="mq:queue:my.queue"/>
Yes see the scheduled polling consumer: http://camel.apache.org/polling-consumer.html
You can specify on the mybatis endpoint that the scheduler is cron and then setup the cron value as well. See that doc for more details.
Also I wrote a little blog once: http://www.davsclaus.com/2013/08/apache-camel-212-even-easier-cron.html its about the file component but its the same for mybatis.
I'm getting a java.lang.OutOfMemoryError: unable to create new native thread error during transfer of around 20 files using SMB endpoint.
Camel version 2.13.
The route itself is quite simple:
<route id="Filetransfer">
<from uri="ftp://user#server//source/map?password=pwd&include=fileA.*.csv|fileB.*.csv|fileC.*.csv|fileD.*.csv|fileE.*.csv|fileF.*.csv&move=save&consumer.delay=30000" />
<log message="${routeId}: ${header.CamelFileName}" />
<to uri="smb://domain;user#server/target/map?password=pwd"/>
</route>
When I check the number of threads in Hawtio dashboard the thread count is hitting a peak of 1000. The route executes correctly when only some small files are transferred. When some biggger
files (>5Mb, >100.000 lines) are transferred, the route gives the error.
When I replace the SMB endpoint with a FILE endpoint like <to uri="file:///tmp/camel"/> the route also executes correctly, and all the files are transferred.
Splitting the file per line first, and then use the Append option in the SMB endpoint causes the same error.
What can I do to make the SMB endpoint work, regardless the size of the files?
My use case is to poll a local directory for a list of new files periodically, and then upload them to a FTP server in 1 connection. The Camel route is defined in Spring XML as follows:
<route>
<from uri="file:data/inbox?noop=true&delay=1000&maxMessagesPerPoll=3" />
<to uri="ftp:uid:xxxxx#host:21/data?disconnect=false"/>
</route>
The route is functioning well, except that the FTP connection will retain connected until the FTP server timeout my connection. I hope to reuse the same connection to upload a batch of files and then close the connection immediately when the last file in the batch completed the upload. How can achieve this in Camel?
This is not possible currently. You will need to write some code to do the disconnect yourself.
You are welcome to log a JIRA to enhance this in camel-ftp: https://issues.apache.org/activemq/browse/CAMEL. For example a new option to disconnectOnBatchComplete.
There might be a way but it is not pretty.
You could try to wrap your route based on a cronSchedulePolicy. So say you kick start the route once every hour and poll the directory and send the files. Then you simply add a stop(). Not sure if the stop is exactly the same in the xml dsl. Alternatively, you could also write that onExchangeComplete(new Processor(StopProcessor(routeId)) and inside that processor you via exchange.getContext.stopRoute(routeid) stop the route. Again this depends on your requirements allow you to do this.
<route>
<from uri="file:data/inbox?noop=true&delay=1000&maxMessagesPerPoll=3" />
<to uri="ftp:uid:xxxxx#host:21/data?disconnect=false"/>
<stop/>
</route>
I'm using "Fuse Tooling Routes Editor" (aka "Fuse Integration Editor", aka "JBoss Fuse Tooling Apache Camel Editor"), described for example here. The version is "Nightly build version 8.0.0.v20150805-1820-H573-MASTER".
I'd like to create a Camel route having a multicast which aggregates the responses it receives from the components it sends a message to, and then forwards the aggregate to a single final receiver. This is certainly doable in Camel, as one of the parameters of a multicast, strategyRef, has the description:
Refers to an AggregationStrategy to be used to assemble the replies from the multicasts, into a single outgoing message from the Multicast. By default Camel will use the last reply as the outgoing message.
However, when I write the following set of routes in my camel-context.xml (which compiles and runs fine):
<route>
<from uri="direct:a"/>
<setExchangePattern pattern="InOut"/>
<multicast strategyRef="x">
<to uri="direct:b"/>
<to uri="direct:c"/>
</multicast>
<log message="This flow works!"/>
<to uri="mock:p"/>
</route>
<route>
<from uri="direct:b"/>
<to uri="mock:q"/>
</route>
<route>
<from uri="direct:c"/>
<to uri="mock:r"/>
</route>
and then click to go to the visual editor, it produces the following (incorrect) picture:
When I switch back to the XML editing, my routes are automatically changed to:
<route>
<from uri="direct:a"/>
<setExchangePattern pattern="InOut"/>
<log message="This flow works!"/>
<to uri="mock:p"/>
</route>
<route>
<from uri="direct:b"/>
<to uri="mock:q"/>
</route>
<route>
<from uri="direct:c"/>
<to uri="mock:r"/>
</route>
And on switching to the editor once again, I get the picture:
This seems like a bug in the editor, but perhaps I'm doing something wrong here?
Many thanks!
Edit:
We found that indeed this used to be an issue logged with the Fuse Camel editor, which however should have been fixed in version 7.1 of the tooling.
that seems to be a bug in the editor. Thank you for reporting it.
I reopened the original issue in Jira. You can track the progress there.
Lars