I have a route which picks up a file, splits it into individual records, and posts these records to a JMS topic.
from("ftp:..."
.unmarshal(bindy)
.split(body())
.marshal(jaxb)
.to("activemq:topic:myTopic");
This has been working fine, until recently something went bizarrely wrong with ActiveMQ, and it successfully processed the first few messages in the file and then gave some bizarre exceptions. This resulted in the consumer assuming that the exchange had failed, and thus not archiving the file, and then reprocessing it. This time it succeeded, but that meant that the records that had already been processed had been repeated.
I've been reading about using transactions with JMS and Camel, but I can't understand how I get it to include all the records generated after the split into a transaction, such that if something goes wrong, the file is left, but any previously "successful" posts to the topic are ignored.
Does this require that shared units of work are enabled for the splitter?
As far as I could see, the .transacted()
instruction applies to the consumer rather than the producer, and as I understand it, the file based components aren't transacted anyway.
How do I ensure that I get an "all or nothing" gets posted to the topic for each file consumed?
Thanks for looking!