|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteneter.messaging.messagingsystems.composites.bufferedmessagingcomposit.BufferedMessagingFactory
public class BufferedMessagingFactory
Extension allowing to work offline until the connection is available.
The buffered messaging is intended to overcome relatively short time intervals when the connection is not available.
It means the buffered messaging is able to hide unavailable connection and work offline while
trying to reconnect.
If the connection is not available, the buffered messaging stores sent messages (and sent response messages)
in the buffer and sends them when the connection is established.
Note:
The buffered messaging does not require that both communicating parts create channels with buffered messaging factory.
It means, e.g. the duplex output channel created with buffered messaging with underlying TCP, can send messages
directly to the duplex input channel created with just TCP messaging factory.
The following example shows how to use buffered messaging e.g. if the connection can get temporarily lost:
// 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 Summary | |
---|---|
BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging)
Constructs the factory with default parameters. |
|
BufferedMessagingFactory(IMessagingSystemFactory underlyingMessaging,
long maxOfflineTime)
Constructs the factory from the 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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |