I have a route which basically transfers the data from one database table to the other. Producer and consumers are JPA endpoints. Simplified:
from(producer)
.process(new StagingEventTransformer())
.to(consumer);
What I'm currently want to catch is a persistence exception on the consumer. This could be the case if a database constraint (e.g. not null on a column) is not matched.
The ".onException(Exception.class)" did not catch the exception both on route and global level.
Currently, the message will be deleted from the producer database table without adding it to the consumer table because of the exception. This means that it could be possible to lose messages here.
So, how can i improve my exception handling to be sure that the entry in the producer table will only be deleted if the insert in the consumer table is successful?
Thanks in advance for your help