Class 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 of deliverMessageTowardsTransport(Message), and calling HostSide.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).

  • Constructor Details

    • AbstractSimpleTransport

      public AbstractSimpleTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters params) throws IllegalArgumentException, 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:
      IllegalArgumentException - should be thrown from a plug-in's constructor if the configuration is invalid.
      Exception - can be thrown to indicate an internal error.
      Since:
      9.12.0.1
  • Method Details

    • sendBatchTowardsTransport

      public void sendBatchTowardsTransport(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 Exception
      Deliver an individual non-null message. If this method throws then the exception will be logged and the message dropped.
      Throws:
      Exception
    • deliverNullPayloadTowardsTransport

      public void deliverNullPayloadTowardsTransport(Message message) throws 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:
      Exception
    • handleException

      public void handleException(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)