Class JMSRequestSink

java.lang.Object
no.mnemonic.messaging.requestsink.jms.AbstractJMSRequestBase
no.mnemonic.messaging.requestsink.jms.JMSRequestSink
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.jms.MessageListener, no.mnemonic.commons.component.LifecycleAspect, no.mnemonic.commons.metrics.MetricAspect, no.mnemonic.commons.utilities.AppendMembers, RequestSink

public class JMSRequestSink extends AbstractJMSRequestBase implements RequestSink, javax.jms.MessageListener, no.mnemonic.commons.metrics.MetricAspect
JMSRequestSink is a JMS implementation of the RequestSink using JMS, communicating over JMS to a corresponding JMSRequestProxy.

   ------------        ------------------                     -------------------     ---------------
   | Client   |  --   | JMSRequestSink | ------- JMS -------  | JMSRequestProxy |  -- | RequestSink |
   ------------        ------------------                     -------------------     ---------------
 

The messages must implement the Message interface, and contain a callID and a timestamp. Other than this, the JMSRequestSink does not care about the format of the sent messages, but will deliver them to the RequestSink on the other side, where they must be handled.

The messaging protocol between a JMSRequestSink and JMSRequestProxy is private between these entities, and should be concidered transparent.

The implementation will serialize messages to bytes. If upstream messages are above the configured maxMessageSize, the JMSRequestSink will create an upload channel to establish a temporary queue for uploading, and will fragment the upload message into multiple messages on the upload channel. This avoids very large JMS messages for upload.

For download, the server RequestSink can choose to send multiple replies on the same reply channel, and can use this to stream the results back to the client.

The JMSRequestSink uses a single multiplexed temporary response to receive all responses for signalled requests. This reduces the load on the JMS server infrastructure, and gives a more stable system in clustered/networked JMS environments, since it reduces the need for signalling and cross-network state updates. However, the response queue may become stale, i.e. upon single server restart or network reconfiguration. Clients should notify the requestsink when unexpected timeout occurs, to request that the temporary queue be recreated.

The protocol between the sink and the proxy is versioned. The proxy must support the version used by the sink, or the request will fail. The sink can specify a lesser protocol version, allowing a rolling upgrade by upgrading the code first, but keep using previous version until all components are supporting the new protocol version.

The default protocol version is V2, so clients must explicitly enable higher protocol versions.

Protocol change history: V1 - Initial version, supports requests with multiple replies (streaming result) and upload channel for fragmented request (for large request messages) V2 - Added support for fragmented response (for large single-object response messages) V3 - Added support for custom message serializers. The client serializer must be supported on the server side, but the server can support multiple serializers.

  • Method Details

    • getMetrics

      public no.mnemonic.commons.metrics.Metrics getMetrics() throws no.mnemonic.commons.metrics.MetricException
      Specified by:
      getMetrics in interface no.mnemonic.commons.metrics.MetricAspect
      Throws:
      no.mnemonic.commons.metrics.MetricException
    • onMessage

      public void onMessage(javax.jms.Message message)
      Specified by:
      onMessage in interface javax.jms.MessageListener
    • signal

      public <T extends RequestContext> T signal(Message msg, T signalContext, long maxWait)
      Specified by:
      signal in interface RequestSink
    • abort

      public void abort(String callID)
      Specified by:
      abort in interface RequestSink
    • onException

      public void onException(javax.jms.JMSException e)
      Specified by:
      onException in interface javax.jms.ExceptionListener
    • startComponent

      public void startComponent()
      Specified by:
      startComponent in interface no.mnemonic.commons.component.LifecycleAspect
    • stopComponent

      public void stopComponent()
      Specified by:
      stopComponent in interface no.mnemonic.commons.component.LifecycleAspect
    • builder

      public static JMSRequestSink.Builder builder()