com.apama.services.event
Interface IEventService


public interface IEventService

IEventService is an interface that represents the public API to the EventService.

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.

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.

See Also:
IEventServiceChannel

Field Summary
static java.lang.String PROPERTY_CONNECTED
          Property name for events fired that signal a change in the connectivity of the event service.
 
Method Summary
 IEventServiceChannel addChannel(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> channelConfig)
          Create an EventServiceChannel specifically for listening to a given channel or channels.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add a change listener for the specified property.
 void destroy()
          Identical to the dispose() method, retained for backwards compatibility only.
 void dispose()
          Disconnects this service from the Correlator and stops background threads.
 IEventServiceChannel getChannel(java.lang.String channelName)
          Get an EventServiceChannel for a given channel or 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)
          Remove an EventServiceChannel for a given channel or 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)
          Set the disconnect if slow property.
 

Field Detail

PROPERTY_CONNECTED

static final java.lang.String PROPERTY_CONNECTED
Property name for events fired that signal a change in the connectivity of the event service.

See Also:
isConnected(), Constant Field Values
Method Detail

addPropertyChangeListener

void addPropertyChangeListener(java.lang.String propertyName,
                               java.beans.PropertyChangeListener listener)
Add a change listener for the specified property.

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.

Parameters:
propertyName - the name of the property to listen on.
listener - the listener to be added.

removePropertyChangeListener

void removePropertyChangeListener(java.lang.String propertyName,
                                  java.beans.PropertyChangeListener listener)
Remove the property change listener for the specified property.

Parameters:
propertyName - the name of the property to listen on.
listener - the listener to be added.

getEngineClient

EngineClientInterface getEngineClient()
Get a handle on the underlying EngineClient.

Returns:
the EngineClientInterface implementation used by this service, or null if the EventService has been destroyed.

addChannel

IEventServiceChannel addChannel(java.lang.String channelName,
                                java.util.Map<java.lang.String,java.lang.Object> channelConfig)
Create an EventServiceChannel specifically for listening to a given channel or channels.

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.

Parameters:
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.
Returns:
A new or pre-existing EventServiceChannel.

getChannel

IEventServiceChannel getChannel(java.lang.String channelName)
Get an EventServiceChannel for a given channel or channels.

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.

Parameters:
channelName - The name of the channel for a previously added EventServiceChannel (may be a comma separated list).
Returns:
the requested EventServiceChannel, or null is none is found.

removeChannel

void removeChannel(java.lang.String channelName)
Remove an EventServiceChannel for a given channel or channels.

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.

Parameters:
channelName - The name of the channel for a previously added EventServiceChannel (may be a comma separated list).

sendEvent

void sendEvent(Event event)
               throws EngineException
Send an event to the Correlator using the EngineClient.

Parameters:
event - The event to be sent.
Throws:
EngineException
See Also:
For information about how to construct an Event object.

isConnected

boolean isConnected()
Get the current connectivity of the event service. This value is true when everything is fine and events can be sent and received, but false if any part of the connection has a problem (for example, if the entire connection is lost, or if the remote engine has disconnected the service's consumers for being slow).

Returns:
true if the connection is fully working, false if there is a problem.
See Also:
PROPERTY_CONNECTED

dispose

void dispose()
Disconnects this service from the Correlator and stops background threads.

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.


destroy

void destroy()
Identical to the dispose() method, retained for backwards compatibility only.


isDestroyed

boolean isDestroyed()
Determine if this service (not the Correlator) is disposed.

Returns:
true if already disposed, false otherwise.

setDisconnectIfSlow

void setDisconnectIfSlow(boolean disconnectIfSlow)
Set the disconnect if slow property.

This 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 miniumum reconnection time set using EngineClientInterface.setReconnectPeriod(long).



Submit a bug or feature
Copyright (c) 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG