Hi,
I've been working on a pull request to add a 'pause' and 'resume' feature to the message bus. Here are the methods from the new interface 'PubSubPauseSupport' with Javadoc comments to explain the concept:
/**
* Pauses event publishing. All messages submitted via {@link #publish(Object)} will be stored in a queue until
* {@link #resume()} is called. Any subsequent calls to this method before a call to {@link #resume()} will have no
* effect.
*/
void pause();
/**
* Resumes event publishing. All messages enqueued since the first call to {@link #pause()} will be subsequently
* flushed and published in the order that they arrived. Does nothing if the runtime is not currently in a paused
* state from a call to {@link #pause()}.
*/
void resume();
/**
* @return true if this PubSubPauseSupport is currently paused, false otherwise.
*/
boolean isPaused();
This is especially useful in event-based applications that go through "transitions" i.e. a short period of time in which no Handler is able to receive events, yet it is problematic for inbound events to be completely lost. Being able to 'pause' the event publishing, queueing published events until it is resumed, solves this problem. There shouldn't be any performance cost on normal operation either.
The only thing that's tripping me up a bit is how to support publishAsync calls? Should AbstractSyncAsyncMessageBus keep another queue separate from the normal BlockingQueue or should that be the implementation's job?
I would appreciate any feedback, and let me know if you want me to go ahead an push the pull request so you can see the rest of the changes.
Hi,
I've been working on a pull request to add a 'pause' and 'resume' feature to the message bus. Here are the methods from the new interface 'PubSubPauseSupport' with Javadoc comments to explain the concept:
This is especially useful in event-based applications that go through "transitions" i.e. a short period of time in which no Handler is able to receive events, yet it is problematic for inbound events to be completely lost. Being able to 'pause' the event publishing, queueing published events until it is resumed, solves this problem. There shouldn't be any performance cost on normal operation either.
The only thing that's tripping me up a bit is how to support
publishAsynccalls? ShouldAbstractSyncAsyncMessageBuskeep another queue separate from the normalBlockingQueueor should that be the implementation's job?I would appreciate any feedback, and let me know if you want me to go ahead an push the pull request so you can see the rest of the changes.