be shared new DatabaseQueryingHandler()); } } ... public static void main(String[] args) { {@link ServerBootstrap} bootstrap = ...;...
{@link ExecutionHandler} executionHandler = new {@link ExecutionHandler}( new {@link OrderedMemoryAwareThreadPoolExecutor}(16, 1048576, 1048576)) bootstrap.setPipelineFactory( new DatabaseGatewayPipelineFactory(executionHandler)); ... bootstrap.bind(...); ... while (!isServerReadyToShutDown()) { // ... wait ... } bootstrap.releaseExternalResources();
executionHandler.releaseExternalResources(); } Please refer to {@link OrderedMemoryAwareThreadPoolExecutor} for thedetailed information about how the event order is guaranteed.
SEDA (Staged Event-Driven Architecture)
You can implement an alternative thread model such as
SEDA by adding more than one {@link ExecutionHandler} to the pipeline.
Using other {@link Executor} implementation
Although it's recommended to use {@link OrderedMemoryAwareThreadPoolExecutor}, you can use other {@link Executor} implementations. However, you must notethat other {@link Executor} implementation might break your applicationbecause they often do not maintain event execution order nor interact with I/O threads to control the incoming traffic and avoid {@link OutOfMemoryError}.
@apiviz.landmark
@apiviz.has java.util.concurrent.ThreadPoolExecutor