public interface IEventService
extends java.lang.AutoCloseable
IEventService is an interface that forms part of the service style high-level public interface to the Correlator with a focus on only dealing with Events and consumer channels. The EventService automatically takes care of connecting to the Correlator in the background, and reconnecting when disconnected.
IEventService users who need to take action when the connectivity of the service
changes should usually add a listener for the PROPERTY_CONNECTED
IEventService
property (rather than adding listeners to the lower engine client layer which can
cause locking issues).
Use EventType
and its associated classes to parse and generate Event
objects for receiving and sending using this class.
IEventServiceChannel
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTY_CONNECTED
Property name for events fired that signal a change in the connectivity of the event service.
|
Modifier and Type | Method and Description |
---|---|
IEventServiceChannel |
addChannel(java.lang.String[] channelNames,
java.util.Map<java.lang.String,java.lang.Object> channelConfig)
Create an EventServiceChannel specifically for listening to given channels.
|
IEventServiceChannel |
addChannel(java.lang.String channelName,
java.util.Map<java.lang.String,java.lang.Object> channelConfig)
Deprecated.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Add a change listener for the specified property.
|
void |
close()
Disconnects this service from the Correlator and stops background threads.
|
void |
destroy()
Deprecated.
Replaced by
close() as of Apama version 9.10 |
void |
dispose()
Deprecated.
Replaced by
close() as of Apama version 9.10 |
IEventServiceChannel |
getChannel(java.lang.String channelName)
Deprecated.
|
IEventServiceChannel |
getChannel(java.lang.String[] channelNames)
Get an EventServiceChannel for given channels
This is the recommended method going forward providing array of channels.
|
EngineClientInterface |
getEngineClient()
Get a handle on the underlying EngineClient.
|
boolean |
isConnected()
Get the current connectivity of the event service.
|
boolean |
isDestroyed()
Determine if this service (not the Correlator) is disposed.
|
void |
removeChannel(java.lang.String channelName)
Deprecated.
|
void |
removeChannel(java.lang.String[] channelNames)
Remove an EventServiceChannel for given channels.
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Remove the property change listener for the specified property.
|
void |
sendEvent(Event event)
Send an event to the Correlator using the EngineClient.
|
void |
setDisconnectIfSlow(boolean disconnectIfSlow)
Deprecated.
see
EventServiceFactory#createEventService(String, int, boolean)
to disconnect any slow receiver |
static final java.lang.String PROPERTY_CONNECTED
isConnected()
,
Constant Field Valuesvoid addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
All property change callbacks on the IEventService object are guaranteed to be invoked asynchronously with no locks held (but each property's callbacks will still be fired in the order the property changes occurred). This means it is safe to call any engine client or event service method (except dispose) from a listener implementation. However it also means that by the time the listener fires the current value of the property might have changed since the change notification was fired.
propertyName
- the name of the property to listen on.listener
- the listener to be added.void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- the name of the property to listen on.listener
- the listener to be added.EngineClientInterface getEngineClient()
IEventServiceChannel addChannel(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> channelConfig)
addChannel(String[], Map)
The channelName parameter is normalized by tokenizing and the tokens added to a SortedSet. If an EventServiceChannel has already been created for the normalized channelName then the existing instance will be returned.
Valid channel name delimiters are the comma, space, and tab characters.
Note: Even if the channelConfig supplied are different to those of an existing EventServiceChannel for the normalized channelName, a new EventServiceChannel will not be created.
channelName
- The name of the channel to receive events on (may be a comma separated list).channelConfig
- Configuration properties of the EventServiceChannel. See also ChannelConfig
.IEventServiceChannel addChannel(java.lang.String[] channelNames, java.util.Map<java.lang.String,java.lang.Object> channelConfig)
addChannel(String, Map)
is deprecated.
The channelNames parameter contains names of channels which is normalized by sorting it. If an EventServiceChannel has already been created for the normalized channelNames then the existing instance will be returned.
Note: Even if the channelConfig supplied are different to those of an existing EventServiceChannel for the normalized channelNames, a new EventServiceChannel will not be created.
channelNames
- The names of the channels to receive events onchannelConfig
- Configuration properties of the EventServiceChannel. See also ChannelConfig
.IEventServiceChannel getChannel(java.lang.String channelName)
getChannel(String[])
The channelName parameter is normalized by tokenizing and the tokens added to a SortedSet. If an EventServiceChannel has already been created for the normalized channelName then that instance will be returned, otherwise null is returned.
Valid channel name delimiters are the comma, space, and tab characters.
channelName
- The name of the channel for a previously added EventServiceChannel (may be a comma separated list).IEventServiceChannel getChannel(java.lang.String[] channelNames)
getChannel(String)
is deprecated.
The channelNames parameter contains names of channels which is normalized by sorting it. If an EventServiceChannel has already been created for the normalized channelNames, then that instance will be returned, otherwise null is returned.
channelNames
- Names of channels for a previously added EventServiceChannelvoid removeChannel(java.lang.String channelName)
removeChannel(String[])
This will cause the EventServiceChannel to be destroyed and disconnected from the Correlator. Any client code that has a reference to the EventServiceChannel will not receive any more events.
If no EventServiceChannel is found with the given channelName then a warning is logged, and the call is a no-op.
channelName
- The name of the channel for a previously added EventServiceChannel (may be a comma separated list).void removeChannel(java.lang.String[] channelNames)
removeChannel(String)
is deprecated.
This will cause the EventServiceChannel to be destroyed and disconnected from the Correlator. Any client code that has a reference to the EventServiceChannel will not receive any more events.
If no EventServiceChannel is found with given channelNames then a warning is logged, and the call is a no-op.
channelNames
- Names of channels for a previously added EventServiceChannelvoid sendEvent(Event event) throws EngineException
event
- The event to be sent.EngineException
For information about how to construct an Event object.
boolean isConnected()
PROPERTY_CONNECTED
void close()
This will cause all EventServiceChannels to be removed and disconnected from the correlator, and the underlying EngineClient will then also be disconnected.
Java client applications should dispose any created event services once they are done with using them. To avoid deadlock, this method should never be invoked synchronously from an EventService listener.
This is a one-time operation - the service cannot be restarted.
This method is invoked automatically on objects managed by the try-with-resources statement.
close
in interface java.lang.AutoCloseable
AutoCloseable.close()
@Deprecated void dispose()
close()
as of Apama version 9.10This will cause all EventServiceChannels to be removed and disconnected from the correlator, and the underlying EngineClient will then also be disconnected.
Java client applications should dispose any created event services once they are done with using them. To avoid deadlock, this method should never be invoked synchronously from an EventService listener.
This is a one-time operation - the service cannot be restarted.
@Deprecated void destroy()
close()
as of Apama version 9.10dispose()
method, retained for backwards compatibility only.boolean isDestroyed()
@Deprecated void setDisconnectIfSlow(boolean disconnectIfSlow)
EventServiceFactory#createEventService(String, int, boolean)
to disconnect any slow receiverThis must be set before any EventService channels are created, or any other event receiver to the component this event service listens to, as only the first setting on a connection is used.
If an EventService's consumers are disconnected for being slow, the
EventService will notify the application using the PROPERTY_CONNECTED
property and attempt to disconnect and reconnect the client automatically,
subject to any minimum reconnection time set using
EngineClientInterface.setReconnectPeriod(long)
.
Submit a bug or feature
Copyright (c) 2013-2017 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.