Package com.softwareag.connectivity
Class AbstractSimpleTransport
- java.lang.Object
-
- com.softwareag.connectivity.ConnectivityPlugin
-
- com.softwareag.connectivity.AbstractTransport
-
- com.softwareag.connectivity.AbstractSimpleTransport
-
- All Implemented Interfaces:
TransportSide
public abstract class AbstractSimpleTransport extends AbstractTransport
Base class that allows simplified implementation of transport plug-ins. Handles batches of messages and ignoring null payload messages (by default). Plug-in authors will typically extend this class, providing a valid constructor, an implementation ofdeliverMessageTowardsTransport(Message)
, and callingHostSide.sendBatchTowardsHost(List)
to send messages in the other direction.Subclasses should provide a constructor with the same signature as
AbstractSimpleTransport(org.slf4j.Logger, PluginConstructorParameters.TransportConstructorParameters)
.
-
-
Field Summary
-
Fields inherited from class com.softwareag.connectivity.AbstractTransport
hostSide
-
Fields inherited from class com.softwareag.connectivity.ConnectivityPlugin
chainId, config, CONNECTIVITY_API_VERSION, host, logger, pluginName
-
-
Constructor Summary
Constructors Constructor Description AbstractSimpleTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters params)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
deliverMessageTowardsTransport(Message message)
Deliver an individual non-null message.void
deliverNullPayloadTowardsTransport(Message message)
Deliver an individual null-payload message.void
handleException(java.lang.Exception ex, Message message, boolean towardsTransport)
Handle exception thrown from delivering messages.void
sendBatchTowardsTransport(java.util.List<Message> messages)
Deliver a batch of messages and pass them on to the next plug-in synchronously.-
Methods inherited from class com.softwareag.connectivity.AbstractTransport
hostReady, setNextTowardsHost, shutdown, start, toString
-
Methods inherited from class com.softwareag.connectivity.ConnectivityPlugin
getStatusReporter
-
-
-
-
Constructor Detail
-
AbstractSimpleTransport
public AbstractSimpleTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters params) throws java.lang.IllegalArgumentException, java.lang.Exception
Constructor. A subclass should provide its own constructor with the same signature as this one. This base class makes the parameters passed into its constructor available as member fields or methods for use by the subclass.- Parameters:
logger
- a slf4j Logger object which can be used to log to the host log file.params
- an extensible interface providing access to the configuration for this plug-in and other capabilities.- Throws:
java.lang.IllegalArgumentException
- should be thrown from a plug-in's constructor if the configuration is invalid.java.lang.Exception
- can be thrown to indicate an internal error.- Since:
- 9.12.0.1
-
-
Method Detail
-
sendBatchTowardsTransport
public void sendBatchTowardsTransport(java.util.List<Message> messages)
Deliver a batch of messages and pass them on to the next plug-in synchronously. For each message passed in, calls deliverMessageTowardsTransport or deliverNullPayloadTowardsTransport (if the payload was null). On an exception, call handleException.If the transport can deliver multiple events in a batch more efficiently, then it should override this method.
-
deliverMessageTowardsTransport
public abstract void deliverMessageTowardsTransport(Message message) throws java.lang.Exception
Deliver an individual non-null message. If this method throws then the exception will be logged and the message dropped.- Throws:
java.lang.Exception
-
deliverNullPayloadTowardsTransport
public void deliverNullPayloadTowardsTransport(Message message) throws java.lang.Exception
Deliver an individual null-payload message. By convention, most plug-ins silently ignore messages with null payloads without delivering them. Thus, the default implementation of this method is a no-op.- Throws:
java.lang.Exception
-
handleException
public void handleException(java.lang.Exception ex, Message message, boolean towardsTransport)
Handle exception thrown from delivering messages. The default implementation is to only log (thus discarding this message, but not others in the same batch)
-
-