At what frequency, Dispatch method dispatches the messages on the Reactor Channel?
The below code snippet is from the Consumer Value Add example. On Executing this, looks like the reactor dispatches the messages after every 10 seconds. But doesn't look like it is configured in the example code. I wanted to ask if this Reactor's implicit behavior to dispatch the messages after every 10 seconds or this can be controlled by the API user?
// dispatch until no more messages
while ((ret = reactorChnl.dispatch(dispatchOptions, errorInfo)) > 0) {}
if (ret == ReactorReturnCodes.FAILURE)
{
if (reactorChnl.state() != ReactorChannel.State.CLOSED &&
reactorChnl.state() != ReactorChannel.State.DOWN_RECONNECTING)
{
System.out.println("ReactorChannel dispatch failed: " + ret + "(" + errorInfo.error().text() + ")");
uninitialize();
System.exit(ReactorReturnCodes.FAILURE);
}
}
Find more posts tagged with
- A positive value if dispatching succeeded and
there are more messages to process - ReactorReturnCodes.SUCCESS if dispatching
succeeded and there are no more messages to process - ReactorReturnCodes.FAILURE, if dispatching
failed (refer to errorInfo for additional information)
In the Consumer Value Add example, reactorChnl.dispatch()
will be called after selector.select() returns and there is data available to
be read in the reactor channel.
private void run()
{
int selectRetVal, selectTime = 1000;
while (true)
{
Set<SelectionKey> keySet = null;
try
{
selectRetVal = selector.select(selectTime);
if (selectRetVal > 0)
{
keySet = selector.selectedKeys();
}
}
…
}
Then, reactorChnl.dispatch() will be called until there is no more messages to process.
while ((ret = reactorChnl.dispatch(dispatchOptions, errorInfo)) > 0) {}
The return value of ReactorChannel.dispatch() can be:
From this information, the Consumer Value Add example will
dispatch the messages when there are messages available to process. It will not
dispatch the messages after every 10 seconds except the code was modified or
the data comes every 10 seconds.
- A positive value if dispatching succeeded and
there are more messages to process - ReactorReturnCodes.SUCCESS if dispatching
succeeded and there are no more messages to process - ReactorReturnCodes.FAILURE, if dispatching
failed (refer to errorInfo for additional information)
In the Consumer Value Add example, reactorChnl.dispatch()
will be called after selector.select() returns and there is data available to
be read in the reactor channel.
private void run()
{
int selectRetVal, selectTime = 1000;
while (true)
{
Set<SelectionKey> keySet = null;
try
{
selectRetVal = selector.select(selectTime);
if (selectRetVal > 0)
{
keySet = selector.selectedKeys();
}
}
…
}
Then, reactorChnl.dispatch() will be called until there is no more messages to process.
while ((ret = reactorChnl.dispatch(dispatchOptions, errorInfo)) > 0) {}
The return value of ReactorChannel.dispatch() can be:
From this information, the Consumer Value Add example will
dispatch the messages when there are messages available to process. It will not
dispatch the messages after every 10 seconds except the code was modified or
the data comes every 10 seconds.
Reactor dispatch is controlled by dispatchOptions, which is defined by maxMessages to process, which by default is 100. Therefore, usually dispatch fully dispatches the messages available on the descriptor, and if more is expected, it can be set higher.