public class MonitoredMessagingFactory extends java.lang.Object implements IMessagingSystemFactory
// 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 and Description |
---|
MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging)
Constructs the factory with default settings.
|
MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging,
long pingFrequency,
long pingReceiveTimeout)
Constructs the factory from specified parameters.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.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 automaticallyjava.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 millisecondspublic long getPingFrequency()
public MonitoredMessagingFactory setReceiveTimeout(long milliseconds)
milliseconds
- time in millisecondspublic long getReceiveTimeout()
public MonitoredMessagingFactory setSerializer(ISerializer pingSerializer)
pingSerializer
- serializer.public MonitoredMessagingFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
inputChannelThreading
- threading modelpublic IThreadDispatcherProvider getInputChannelThreading()
public MonitoredMessagingFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
outputChannelThreading
- public IThreadDispatcherProvider getOutputChannelThreading()
public ISerializer getSerializer()