public abstract class AbstractEventTransport extends java.lang.Object implements EventTransport
In addition to implementing the abstract methods here and in the EventTransport interface, valid subclasses must provide a constructor with the same signature as the one provided here. Note that the IAF provides NO guarantees about what threads that will be used to call these functions, so to ensure correct operation care must be taken to use locking where required.
API_VERSION
Constructor and Description |
---|
AbstractEventTransport(java.lang.String name,
EventTransportProperty[] properties,
TimestampConfig timestampConfig)
Construct a new instance of AbstractEventTransport.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addEventDecoder(java.lang.String name,
EventDecoder decoder)
Add a named event decoder to the set of decoders known to the
transport.
|
abstract void |
cleanup()
Frees any resources allocated by the transport (useful for resources
external to the JVM that were allocated in the constructor).
|
void |
flushDownstream()
Flush any pending transport events into the decoder.
|
void |
flushUpstream()
Flush any pending normalized events onto the external transport.
|
abstract int |
getAPIVersion()
Return the transport API version that the transport was built against.
|
int |
getCapabilities()
Return the capabilities of the transport.
|
abstract TransportStatus |
getStatus()
Return a
TransportStatus or ExtendedTransportStatus
object containing up-to-date status information for the transport. |
abstract void |
removeEventDecoder(java.lang.String name)
Remove a named event decoder from the set of decoders known to the
transport.
|
abstract void |
sendTransportEvent(java.lang.Object event,
TimestampSet timestamps)
This is the method that a codec layer plug-in calls when it receives
a translated upstream Apama event that needs to be sent on to an event
transport for transmission to an external message sink.
|
abstract void |
start()
Establish a connection and start processing incoming data from the
external transport.
|
abstract void |
stop()
Stop processing incoming data from the external transport, typically
by pausing or closing down connections.
|
java.lang.String |
toString() |
void |
updateProperties(EventTransportProperty[] properties,
TimestampConfig timestampConfig)
Update the configuration of the transport.
|
public AbstractEventTransport(java.lang.String name, EventTransportProperty[] properties, TimestampConfig timestampConfig) throws TransportException
The AbstractEventTransport implementation does nothing, but subclasses
should make use of the arguments to initialize the transport.
A typical constructor would create a logger using the plug-in name provided
and make a call to the updateProperties(EventTransportProperty[], TimestampConfig)
method to deal with the
initial property set passed in, and perform any other initialization
operations required for the particular transport being developed.
name
- The transport name, as specified in the IAF config fileproperties
- The transport property set specified in the IAF
configuration filetimestampConfig
- Timestamp recording/logging settings from the
IAF configuration fileTransportException
public void updateProperties(EventTransportProperty[] properties, TimestampConfig timestampConfig) throws TransportException
EventTransportProperty
object for each plug-in
property specified in the IAF configuration file (in order). The getName and getValue
methods allow the plug-in to retrieve the name and value of each property as String objects.properties
- The new transport property set specified in the IAF
configuration filetimestampConfig
- Timestamp recording/logging settingsTransportException
public abstract void addEventDecoder(java.lang.String name, EventDecoder decoder) throws TransportException
EventDecoder
could later be retrieved
using a plug-in property (for example, "decoderName") to determine
which of the plug-ins in the map should be used.
Alternatively, if this transport plug-in will only ever be used in an
adapter with just one codec plug-in, this method can be implemented
simply by storing the provided EventDecoder object in an instance field.name
- The name of the decoder to be addeddecoder
- The decoder object instanceTransportException
public abstract void removeEventDecoder(java.lang.String name) throws TransportException
name
- The decoder to be removedTransportException
public void flushUpstream() throws TransportException
TransportException
public void flushDownstream() throws TransportException
TransportException
public abstract void start() throws TransportException
This is where a plug-in should establish a connection to its external message source/sink, often by starting a new thread to process or poll for new downstream messages. Events should not be sent to the correlator until the start method has been called. An adapter should send events to the correlator only after its start() method is called and before the stop() method returns. Therefore we strongly recommend that a transport should not change to a state where it is possible to receive events from any external transport until the start() method has been called. In many cases, adapters will also need to communicate with service monitors in the correlator to ensure that the required monitors and event definitions are injected before they begin to process messages from the external system. This is necessary in order to avoid events from the adapter being lost if the correlator is not yet ready to parse and process them.
TransportException
public abstract void stop() throws TransportException
New events arriving may be blocked, queued or simply dropped, but under no circumstances should any be sent into the adapter until the start() function is called. Adapter authors must ensure that no events are sent to the correlator after stop() has returned (the only exception being rare cases where the transport sends buffered events in the Correlator in the flushDownstream() method, which is called by the IAF after stop()). If necessary any messages that are unavoidably received from the transport after stop() has returned should be blocked, queued or simply dropped.
TransportException
public abstract void cleanup() throws TransportException
TransportException
public abstract TransportStatus getStatus()
TransportStatus
or ExtendedTransportStatus
object containing up-to-date status information for the transport.
This method provides the statistics and status message displayed by
the IAF Watch tool. A typical plug-in will continuously keep track
of the number of messages sent upstream and downstream. Then, when
getStatus is called, these message counts can simply be packaged up
in a new TransportStatus object together with a String describing the
current status of the plug-in (maximum length 1024 characters), and returned.
As an example
public TransportStatus getStatus()
{
String status = (started) ? "Status: Running" : "Status: Not running";
return new TransportStatus(status, totalReceived, totalSent);
}
public abstract int getAPIVersion()
EventTransport.API_VERSION
.public int getCapabilities()
0
.public java.lang.String toString()
toString
in class java.lang.Object
public abstract void sendTransportEvent(java.lang.Object event, TimestampSet timestamps) throws TransportException
sendTransportEvent
in interface EventTransport
event
- An object representing the event to be sent by the
transport, in a format shared by the encoder and transport.timestamps
- A TimestampSet representing the timestamps attached
to the event.TransportException
- Thrown by the transport if any error occurs
sending the message.com.apama.iaf.plugin.EventTransport#sendTransportEvent(java.lang.Object)
Submit a bug or feature
Copyright (c) 2013-2020 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.