public interface EventAsyncConsumer extends EventConsumer
Title: Service Event Fabric Core
Description: Defines the asynchronous Event Consumer.
class MyListener implements FabricEventListener { public void onEvent(ImmutableEventDatagram event) throws FabricEventException { System.out.prinln("Event: " + event.getEventId()); } } ... EventAsyncConsumer consumer = dispatcher.createEventAsyncConsumer("Consumer", new MyListener(), "event.id", null, EventScope.OBSERVABLE, true); consumer.start(); ... consumer.close();
Copyright: Copyright (c) 2010
Company: StreamScape Technologies
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_CLOSE_TIMEOUT |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the underlying event queue of the consumer.
|
void |
close()
Closes the consumer and drops it from the corresponding dispatcher.
|
void |
close(long timeout)
Closes the consumer and drops it from the corresponding dispatcher.
|
void |
forceClose()
Forcibly closes the consumer and drops it from the corresponding dispatcher.
|
int |
getCurrentDepth()
Returns the current number of events in the underlying queue.
|
DeliveryMode |
getDeliveryMode()
Returns a delivery mode of the underlying event queue.
|
long |
getDeliverySpinWait()
Returns a delivery delay (in milliseconds) of the underlying queue.
|
FlowControlMode |
getFlowControlMode()
Returns a flow control mode of the underlying queue.
|
int |
getMaxDepth()
Returns a maximum depth of the underlying queue.
|
boolean |
isStarted()
Checks if a delivery of events to the associated listener is started.
|
boolean |
isSuspended()
Checks if a delivery of events to the associated listener is suspended.
|
void |
resume()
Resumes a delivery of events to the associated listener.
|
void |
setDeliveryMode(DeliveryMode deliveryMode)
Sets a delivery mode of the underlying event queue.
|
void |
setDeliverySpinWait(long deliverySpinWait)
Sets a delivery delay (in milliseconds) of the underlying queue.
|
void |
setFlowControlMode(FlowControlMode flowControlMode)
Sets a flow control mode of the underlying event queue.
|
void |
setMaxDepth(int maxDepth)
Sets a maximum depth of the underlying event queue.
|
void |
start()
Starts a delivery of events to the associated listener.
|
void |
stop()
Stops a delivery of events to the associated listener.
|
void |
suspend()
Suspends a delivery of events to the associated listener.
|
getDispatchMode, getEventFilter, getEventListener, getEventScope, getEventSelector, getGroupName, getName, noLocal, setEventListener, setEventSelector
static final long DEFAULT_CLOSE_TIMEOUT
int getMaxDepth()
void setMaxDepth(int maxDepth) throws IllegalConsumerStateException
100000
events. Once this
limit is reached, new inbound events will be handled based on the
FLOW CONTROL mode defined below.
This method must be invoked only for non-started consumer.
maxDepth
- int the maximum depth of the underlying queue to be set.IllegalConsumerStateException
- if the consumer is started.FlowControlMode getFlowControlMode()
void setFlowControlMode(FlowControlMode flowControlMode) throws IllegalConsumerStateException
FlowControlMode.EXCEPTION
.
This method must be invoked only for non-started consumer.
flowControlMode
- the flow control mode of the underlying queue to be set.IllegalConsumerStateException
- if the consumer is started.DeliveryMode getDeliveryMode()
void setDeliveryMode(DeliveryMode deliveryMode) throws IllegalConsumerStateException
DeliveryMode.ASYNC_PACED
.
This method must be invoked only for non-started consumer.
deliveryMode
- the delivery mode of the underlying queue to be set.IllegalConsumerStateException
- if the consumer is started.long getDeliverySpinWait()
void setDeliverySpinWait(long deliverySpinWait) throws IllegalConsumerStateException
1
millisecond.
This method must be invoked only for non-started consumer.
deliverySpinWait
- the delivery delay of the underlying queue.IllegalConsumerStateException
- if the consumer is started.void start()
void stop()
boolean isStarted()
true
the events delivery is started, false
otherwise.void suspend()
void resume()
boolean isSuspended()
true
the events delivery is suspended, false
otherwise.void clear()
int getCurrentDepth()
void close()
30000L
milliseconds until all remaining events in the underlying event queue
will be processed and stops the delivery thread after that.
close({@value #DEFAULT_CLOSE_TIMEOUT})
.close
in interface EventConsumer
void close(long timeout)
timeout
- the wait time (in milliseconds) for processing of all events in the queue before stopping the delivery thread.void forceClose()
close(0)
.
Under normal circumstances the closing of a consumer that is asynchronous will wait for the underlying event queue primitive to complete delivery of all events. This may cause the closing to take longer then anticipated if there are many pending events. This method will discard all pending events and should be used with caution as it may result in unexpected behavior or data loss.
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.