What happens if an exception is thrown between next() and publish() when using Disruptor or publish() does not get called for some other reason or in acceptable time?

What are recovery / time out techniques to handle such cases?

有帮助吗?

解决方案

Within the Disruptor it self calls to publish are in finally blocks to ensure that they are always called. for example Disruptor.java#1017-1027

As publish marks the slot as available to event handlers they will stall until the call to publish happens.

The recovery strategy is don't break it ;) That is there is no need or point in claiming your slot until you are ready to use it and always call publish. You possibly need some sort of error marker to go in the slot if you don't want to publish the data you've claimed the slot for.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top