deliverMessagesFrom

public Optional<DeliveryStats> deliverMessagesFrom(ShardIndex index)

Delivers the messages put into the shard with the passed index to their targets.

At a given moment of time, exactly one application node may serve messages from a particular shard. Therefore, in scope of this delivery, an approach based on pessimistic locking per-ShardIndex is applied.

In case the given shard is already processed by some node, this method does nothing and returns Optional.empty().

The content of the shard is read and delivered on page-by-page basis. The runtime exceptions occurring while a page is being delivered are accumulated and then the first exception is rethrown, if any.

After all the pages are read, the delivery process is launched again for the same shard. It is required in order to handle the messages, that may have been put to the same shard as an outcome of the first-wave messages.

Once the shard has no more messages to deliver, the delivery process ends, releasing the lock for the respective ShardIndex.

Return

the statistics on the performed delivery, or Optional.empty() if there were no delivery performed

Parameters

index

the shard index to deliver the messages from.