@SPI
public class DeliveryMonitor
extends java.lang.Object
Inbox Delivery
process.
In some cases when a funnel-like Entity
(e.g. some projection of a business report
subscribed to half of the domain events) has a lot of messages in its Inbox
,
the delivery process may be slowed down for other targets in the same shard, while
all the messages are being dispatched the "busy" Entity
. Depending on the number
of messages to deliver, it may take a lot of time.
Environments such as Google AppEngine Standard imply restrictions on the duration of the request processing. Therefore, it may be necessary to stop the message delivery for this shard at some point, and re-schedule the shard processing again by sending another request and thus resetting the processing clock.
Constructor and Description |
---|
DeliveryMonitor() |
Modifier and Type | Method and Description |
---|---|
void |
onDeliveryCompleted(DeliveryStats stats)
Called once some delivery process has completed and the corresponding shard
has been released.
|
void |
onDeliveryStarted(io.spine.server.delivery.ShardIndex index) |
boolean |
shouldContinueAfter(io.spine.server.delivery.DeliveryStage stage)
Determines if the delivery execution should be continued after the given stage is completed.
|
public boolean shouldContinueAfter(io.spine.server.delivery.DeliveryStage stage)
If false
is returned, the ongoing delivery run for the served shard will be
stopped at this application node. The node will release the previously
picked up shard.
To trigger the new delivery processing for this shard, use Delivery.deliverMessagesFrom(ShardIndex).
This method is called synchronously, meaning that the delivery process will not resume until a value is returned from this method call.
stage
- the stage of delivery which has endedtrue
to continue the delivery, false
to stoppublic void onDeliveryCompleted(DeliveryStats stats)
The descendants may override this method to understand when it is safe to pick up the corresponding shard again. Another usage scenario is calculation of the message delivery throughput.
stats
- the statistics of the performed deliverypublic void onDeliveryStarted(io.spine.server.delivery.ShardIndex index)