--short version --

I am trying to unit test a route calling a polling consumer (currently a
http endpoint)
Unfortunately, mock endpoints do not support consumers. Is there an
equivalent to mock endpoints to be used in case of a polling consumer?

I currently replace the endpoint with a seda endpoint where I send the
exchange to be polled to before running the test, but this does not provide
a way to assert if the endpoint has been consumed. Preferably, the test
endpoint also supports a timeout equivalent to the mock endpoint.

--longer version --
I have a requirement where I need to poll an endpoint every x seconds. All
the available messages need to be processed as fast as possible. In case of
an error or no messages found, it should delay the next poll to avoid
having too many error logs.
As this completely describes a scheduled poll consumer with his
backoffTresholds, I decided to use this endpoint. The
DefaultScheduledPollConsumer however does not propagate exceptions while
polling the endpoint, hence the backoffThresholds are never triggered.
To avoid this, I overrided the poll method to rethrow the exception:

> @Override
> protected int poll() throws Exception {
>     Exchange exchange = consumer.receive();
>     getProcessor().process(exchange);
>     if (exchange.getException() != null) {
>       throw exchange.getException();
>     } else {
>       return exchange.getIn().getHeader(exchange.SCHEDULER_POLLED_MESSAGES, 
> true, Boolean.class) ? 1 : 0;
>     }
> }
> While trying to unit test this, I need a polling consumer in which I can
inject messages to be polled.  As described above, I currently replace the
endpoint by a seda endpoint where I can send exchanges to be consumed to.
What I would now like to verify in the test is how many polls on that
endpoint have been done (to make sure the backoffTresholds work as

I hope someone can direct me to either the good component or an alternative
way to solve this requirement.


Reply via email to