Reputation: 7005
I would like to suspend a Camel Kafka consumer (i.e. the route) based on the processing result of the last messages. For example when the 10 last completed messages were failed with the same error, I would like to suspend consuming messages instead of sending thousands of messages to the error topic.
I found that RoutePolicies like ThrottlingInflightRoutePolicy are able to suspend a route based on current inflight exchanges by accessing an InflightRepository.
So my question boils down to: is there also a facility to look back on the last n
completed messages of a route? I think this would allow me to implement a RoutePolicy for my case.
Or, if not, can I build this facility myself by simply build a collection of processing summaries of the last few exchanges in an instance field of the RoutePolicy?
Thanks for any hints.
Upvotes: 1
Views: 373
Reputation: 55525
Yeah there is no built-in route policy for that. We have as you say for throttling, and there is also for cron like scheduling.
So you can build your own, and keep a window of the last N messages and keep track of how many have failed, and then suspend when you hit that threshold.
Mind that what about resuming again? Should that be automated, eg after 5 minutes then try again. Otherwise its a manual step to make the consumer resume again.
Upvotes: 1