Date time = exchange.getProperty(Exchange.RECEIVED_TIMESTAMP, Date.class);
You can use this information to know when the message arrived on the mock. But it also
provides foundation to know the time interval between the previous and next message arrived
on the mock. You can use this to set expectations using the
arrives DSL on the
Camel Component: Mock endpoint.
For example to say that the first message should arrive between 0-2 seconds before the next you can do:
You can also define this as that the second message (0 index based) should arrive no later than 0-2 seconds after the previous:
You can also use between to set a lower bound. For example suppose that it should be between 1-4 seconds:
You can also set the expectation on all messages, for example to say that the gap between them should be at most 1 second:
In the example above we use
seconds as the time unit, but Camel offers
minutes as well.