public class BufferedMessagingFactory extends java.lang.Object implements IMessagingSystemFactory
// Create TCP messaging. IMessagingSystemFactory anUnderlyingMessaging = new TcpMessagingSystemFactory();
// Create buffered messaging that internally uses TCP. IMessagingSystemFactory aMessaging = new BufferedMessagingSystemFactory(anUnderlyingMessaging);
// Create the duplex 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 receive responses. aSender.responseReceived().subscribe(myOnResponseReceived);
// Attach output channel an be able to send messages and receive responses. aSender.attachDuplexOutputChannel(anOutputChannel);
...
// Send a message. // If the connection is broken the message will be stored in the buffer. // Note: The buffered messaging will try to reconnect automatically. aSender.SendMessage("Hello.");
Constructor and Description |
---|
BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging)
Constructs the factory with default parameters.
|
BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging,
long maxOfflineTime)
Constructs the factory from the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
IDuplexInputChannel |
createDuplexInputChannel(java.lang.String channelId)
Creates IBufferedDuplexInputChannel which can receive messages from the output channel and send response messages.
|
IDuplexOutputChannel |
createDuplexOutputChannel(java.lang.String channelId)
Creates IBufferedDuplexOutputChannel which can send messages to the input channel and receive response messages.
|
IDuplexOutputChannel |
createDuplexOutputChannel(java.lang.String channelId,
java.lang.String responseReceiverId)
Creates IBufferedDuplexOutputChannel which can send messages to the input channel and receive response messages.
|
public BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging)
underlyingMessaging
- underlying messaging system e.g. Websocket, TCP, ...public BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging, long maxOfflineTime)
underlyingMessaging
- underlying messaging system e.g. Websocket, TCP, ...maxOfflineTime
- the max time (in milliseconds), the communicating applications can be disconnected.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