|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteneter.messaging.messagingsystems.composites.monitoredmessagingcomposit.MonitoredMessagingFactory
public class MonitoredMessagingFactory
Extension providing the connection monitoring.
The monitored messaging regularly monitors if the connection is still available.
It sends ping messages and receives ping messages in a defined frequency. If sending of the ping message fails
or the ping message is not received within the specified time the connection is considered broken.
The advantage of the monitored messaging is that the disconnection can be detected very early.
When the connection is monitored, the duplex output channel periodically sends 'ping' messages
to the duplex input channel and waits for responses.
If the response comes within the specified timeout, the connection is open.
On the receiver side, the duplex input channel waits for the 'ping' messages and monitors if the connected
duplex output channel is still alive. If the 'ping' message does not come within the specified timeout,
the particular duplex output channel is disconnected.
Note
Channels created by monitored messaging factory cannot communicate with channels, that were not created
by monitored factory. E.g. the channel created with the monitored messaging factory with underlying TCP
will not communicate with channels created directly with TCP messaging factory. The reason is, the
communicating channels must understand the 'ping' communication.
The following example shows how to use monitored messaging:
// Create TCP messaging. IMessagingSystemFactory anUnderlyingMessaging = new TcpMessagingSystemFactory();
// Create monitored messaging which internally uses TCP. IMessagingSystemFactory aMessaging = new MonitoredMessagingSystemFactory(anUnderlyingMessaging);
// Create the output channel. IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:8045/");
// Create message sender to send simple string messages. IDuplexStringMessagesFactory aSenderFactory = new DuplexStringMessagesFactory(); IDuplexStringMessageSender aSender = aSenderFactory.CreateDuplexStringMessageSender();
// Subscribe to detect the disconnection. aSender.connectionClosed().subscribe(myOnConnectionClosed);
// Subscribe to receive responses. aSender.responseReceived().subscribe(myOnResponseReceived);
// Attach output channel an be able to send messages and receive responses. aSender.attachDuplexOutputChannel(anOutputChannel);
...
// Send a message. aSender.SendMessage("Hello.");
Constructor Summary | |
---|---|
MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging)
Constructs the factory with default settings. |
|
MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging,
long pingFrequency,
long pingReceiveTimeout)
Constructs the factory from specified parameters. |
Method Summary | |
---|---|
IDuplexInputChannel |
createDuplexInputChannel(java.lang.String channelId)
Creates the input channel which can receive messages from the output channel and send response messages. |
IDuplexOutputChannel |
createDuplexOutputChannel(java.lang.String channelId)
Creates the output channel which can send messages to the input channel and receive response messages. |
IDuplexOutputChannel |
createDuplexOutputChannel(java.lang.String channelId,
java.lang.String responseReceiverId)
Creates the output channel which can send messages to the input channel and receive response messages. |
IThreadDispatcherProvider |
getInputChannelThreading()
Gets threading mode used for input channels. |
IThreadDispatcherProvider |
getOutputChannelThreading()
Gets threading mode used for output channels. |
long |
getPingFrequency()
Gets the ping frequency. |
long |
getReceiveTimeout()
Gets the time within it the ping message must be received. |
ISerializer |
getSerializer()
Gets the serializer which is used to serialize/deserialize MonitorChannelMessage. |
MonitoredMessagingFactory |
setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
Sets threading mode for input channels. |
MonitoredMessagingFactory |
setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
Sets threading mode for output channels. |
MonitoredMessagingFactory |
setPingFrequency(long milliseconds)
Sets how often the ping message shall be sent. |
MonitoredMessagingFactory |
setReceiveTimeout(long milliseconds)
Sets the time within it the ping message must be received. |
MonitoredMessagingFactory |
setSerializer(ISerializer pingSerializer)
Sets the serializer which shall be used to serialize MonitorChannelMessage. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging)
underlyingMessaging
- underlying messaging system e.g. Websocket, TCP, ...public MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging, long pingFrequency, long pingReceiveTimeout)
underlyingMessaging
- underlying messaging system e.g. Websocket, TCP, ...pingFrequency
- how often the ping message is sent.pingReceiveTimeout
- the maximum time within it the ping message must be received.Method Detail |
---|
public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId) throws java.lang.Exception
createDuplexOutputChannel
in interface IMessagingSystemFactory
channelId
- address of the input channel.
java.lang.Exception
public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId, java.lang.String responseReceiverId) throws java.lang.Exception
createDuplexOutputChannel
in interface IMessagingSystemFactory
channelId
- address of the input channel.responseReceiverId
- unique identifier of the output channel. If the value is null then the identifier is genearated automatically
java.lang.Exception
public IDuplexInputChannel createDuplexInputChannel(java.lang.String channelId) throws java.lang.Exception
createDuplexInputChannel
in interface IMessagingSystemFactory
channelId
- address of the input channel.
java.lang.Exception
public MonitoredMessagingFactory setPingFrequency(long milliseconds)
milliseconds
- time in milliseconds
public long getPingFrequency()
public MonitoredMessagingFactory setReceiveTimeout(long milliseconds)
milliseconds
- time in milliseconds
public long getReceiveTimeout()
public MonitoredMessagingFactory setSerializer(ISerializer pingSerializer)
pingSerializer
- serializer.
public MonitoredMessagingFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
inputChannelThreading
- threading model
public IThreadDispatcherProvider getInputChannelThreading()
public MonitoredMessagingFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
outputChannelThreading
-
public IThreadDispatcherProvider getOutputChannelThreading()
public ISerializer getSerializer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |