Class 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
------------ ------------------ ------------------- --------------- | 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class no.mnemonic.messaging.requestsink.jms.AbstractJMSRequestBase
AbstractJMSRequestBase.BaseBuilder<T extends AbstractJMSRequestBase.BaseBuilder>
-
Field Summary
Fields inherited from class no.mnemonic.messaging.requestsink.jms.AbstractJMSRequestBase
DEFAULT_MAX_MAX_MESSAGE_SIZE, DEFAULT_PRIORITY, MESSAGE_TYPE_CHANNEL_REQUEST, MESSAGE_TYPE_CHANNEL_SETUP, MESSAGE_TYPE_CLIENT_RESPONSE_ACKNOWLEDGEMENT, MESSAGE_TYPE_END_OF_FRAGMENTED_MESSAGE, MESSAGE_TYPE_EXCEPTION, MESSAGE_TYPE_EXTEND_WAIT, MESSAGE_TYPE_SIGNAL, MESSAGE_TYPE_SIGNAL_FRAGMENT, MESSAGE_TYPE_SIGNAL_RESPONSE, MESSAGE_TYPE_STREAM_CLOSED, PROPERTY_DATA_CHECKSUM_MD5, PROPERTY_FRAGMENTS_IDX, PROPERTY_FRAGMENTS_TOTAL, PROPERTY_MESSAGE_TYPE, PROPERTY_REQ_TIMEOUT, PROPERTY_RESPONSE_ID, PROPERTY_SEGMENT_WINDOW_SIZE, PROTOCOL_VERSION_KEY, SERIALIZER_KEY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
static JMSRequestSink.Builder
builder()
no.mnemonic.commons.metrics.Metrics
void
onException
(javax.jms.JMSException e) void
onMessage
(javax.jms.Message message) <T extends RequestContext>
Tvoid
void
Methods inherited from class no.mnemonic.messaging.requestsink.jms.AbstractJMSRequestBase
appendMembers, createSession, toString
-
Method Details
-
getMetrics
public no.mnemonic.commons.metrics.Metrics getMetrics() throws no.mnemonic.commons.metrics.MetricException- Specified by:
getMetrics
in interfaceno.mnemonic.commons.metrics.MetricAspect
- Throws:
no.mnemonic.commons.metrics.MetricException
-
onMessage
public void onMessage(javax.jms.Message message) - Specified by:
onMessage
in interfacejavax.jms.MessageListener
-
signal
- Specified by:
signal
in interfaceRequestSink
-
abort
- Specified by:
abort
in interfaceRequestSink
-
onException
public void onException(javax.jms.JMSException e) - Specified by:
onException
in interfacejavax.jms.ExceptionListener
-
startComponent
public void startComponent()- Specified by:
startComponent
in interfaceno.mnemonic.commons.component.LifecycleAspect
-
stopComponent
public void stopComponent()- Specified by:
stopComponent
in interfaceno.mnemonic.commons.component.LifecycleAspect
-
builder
-