eneter.messaging.messagingsystems.httpmessagingsystem
Class HttpMessagingSystemFactory

java.lang.Object
  extended by eneter.messaging.messagingsystems.httpmessagingsystem.HttpMessagingSystemFactory
All Implemented Interfaces:
IMessagingSystemFactory

public class HttpMessagingSystemFactory
extends java.lang.Object
implements IMessagingSystemFactory

Messaging system delivering messages via HTTP. It creates the communication channels using HTTP for sending and receiving messages. The channel id must be a valid URI address. E.g.: http://127.0.0.1/something/ or https://127.0.0.1/something/.
Because HTTP is request-response based protocol, it does not keep the connection open. Therefore, for the bidirectional communication used by duplex channels, the polling mechanism is used. The duplex output channel regularly polls for response messages and the duplex input channel constantly measures the inactivity time to recognize whether the duplex output channel is still connected.

Notice, to start listening via input channel (or duplex input channel), the application must be executed with sufficient rights. Otherwise the exception will be thrown.


Constructor Summary
HttpMessagingSystemFactory()
          Constructs the factory that will create channels with default settings.
HttpMessagingSystemFactory(int pollingFrequency, int inactivityTimeout)
          Constructs the factory that will create channel with specified settings.
HttpMessagingSystemFactory(int pollingFrequency, int inactivityTimeout, IProtocolFormatter protocolFormatter)
          Constructs the factory that will create channel with specified settings.
 
Method Summary
 IDuplexInputChannel createDuplexInputChannel(java.lang.String channelId)
          Creates the duplex input channel which can receive and send messages to the duplex output channel using UDP.
 IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId)
          Creates duplex output channel which can send and receive messages from the duplex input channel using HTTP.
 IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId, java.lang.String responseReceiverId)
          Creates duplex output channel which can send and receive messages from the duplex input channel using HTTP.
 IThreadDispatcherProvider getInputChannelThreading()
          Gets threading mode used for input channels.
 IThreadDispatcherProvider getOutputChannelThreading()
          Gets threading mode used for output channels.
 HttpMessagingSystemFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
          Sets threading mode for input channels.
 HttpMessagingSystemFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
          Sets threading mode for output channels.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpMessagingSystemFactory

public HttpMessagingSystemFactory()
Constructs the factory that will create channels with default settings. The polling frequency will be 500 ms and the inactivity timeout will be 10 minutes.

The polling frequency and the inactivity time are used only by duplex channels. The polling frequency specifies how often the duplex output channel checks if there are pending response messages. The inactivity time is measured by the duplex input channel and specifies the maximum time, the duplex output channel does not have to poll for messages. If the inactivity time is exceeded, considers the duplex output channel as disconnected.


HttpMessagingSystemFactory

public HttpMessagingSystemFactory(int pollingFrequency,
                                  int inactivityTimeout)
Constructs the factory that will create channel with specified settings. The polling frequency will be 500 ms and the inactivity timeout will be 10 minutes.

The polling frequency and the inactivity time are used only by duplex channels. The polling frequency specifies how often the duplex output channel checks if there are pending response messages. The inactivity time is measured by the duplex input channel and specifies the maximum time, the duplex output channel does not have to poll for messages. If the inactivity time is exceeded, considers the duplex output channel as disconnected.

Parameters:
pollingFrequency - how often the duplex output channel polls for the pending response messages
inactivityTimeout - maximum time (measured by duplex input channel), the duplex output channel does not have to poll for response messages. If the time is exceeded, the duplex output channel is considered as disconnected.

HttpMessagingSystemFactory

public HttpMessagingSystemFactory(int pollingFrequency,
                                  int inactivityTimeout,
                                  IProtocolFormatter protocolFormatter)
Constructs the factory that will create channel with specified settings. The polling frequency will be 500 ms and the inactivity timeout will be 10 minutes.

The polling frequency and the inactivity time are used only by duplex channels. The polling frequency specifies how often the duplex output channel checks if there are pending response messages. The inactivity time is measured by the duplex input channel and specifies the maximum time, the duplex output channel does not have to poll for messages. If the inactivity time is exceeded, considers the duplex output channel as disconnected.

Parameters:
pollingFrequency - how often the duplex output channel polls for the pending response messages
inactivityTimeout - maximum time (measured by duplex input channel), the duplex output channel does not have to poll for response messages. If the time is exceeded, the duplex output channel is considered as disconnected.
protocolFormatter - formatter for low-level messages between duplex output channel and duplex input channel
Method Detail

createDuplexOutputChannel

public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId)
                                               throws java.lang.Exception
Creates duplex output channel which can send and receive messages from the duplex input channel using HTTP. The channel id must be a valid URI address e.g. http://127.0.0.1:8090/something/

The duplex output channel is intended for the bidirectional communication. Therefore, it can send messages to the duplex input channel and receive response messages.

The duplex input channel distinguishes duplex output channels according to the response receiver id. This method generates the unique response receiver id automatically.

The duplex output channel can communicate only with the duplex input channel and not with the input channel.

Specified by:
createDuplexOutputChannel in interface IMessagingSystemFactory
Parameters:
channelId - address of the input channel.
Returns:
output channel
Throws:
java.lang.Exception

createDuplexOutputChannel

public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId,
                                                      java.lang.String responseReceiverId)
                                               throws java.lang.Exception
Creates duplex output channel which can send and receive messages from the duplex input channel using HTTP. The channel id must be a valid URI address e.g. http://127.0.0.1:8090/something/

The duplex output channel is intended for the bidirectional communication. Therefore, it can send messages to the duplex input channel and receive response messages.

The duplex input channel distinguishes duplex output channels according to the response receiver id. This method allows to specified a desired response receiver id. Please notice, the response receiver id is supposed to be unique.

The duplex output channel can communicate only with the duplex input channel and not with the input channel.

Specified by:
createDuplexOutputChannel in interface IMessagingSystemFactory
Parameters:
channelId - address of the input channel.
responseReceiverId - unique identifier of the output channel. If the value is null then the identifier is genearated automatically
Returns:
duplex output channel
Throws:
java.lang.Exception

createDuplexInputChannel

public IDuplexInputChannel createDuplexInputChannel(java.lang.String channelId)
                                             throws java.lang.Exception
Creates the duplex input channel which can receive and send messages to the duplex output channel using UDP. The channel id must be a valid URI address e.g. http://127.0.0.1:8090/something/

The duplex input channel is intended for the bidirectional communication. It can receive messages from the duplex output channel and send back response messages.

The duplex input channel can communicate only with the duplex output channel and not with the output channel.

Specified by:
createDuplexInputChannel in interface IMessagingSystemFactory
Parameters:
channelId - address of the input channel.
Returns:
input channel
Throws:
java.lang.Exception

setInputChannelThreading

public HttpMessagingSystemFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
Sets threading mode for input channels.

Parameters:
inputChannelThreading - threading model
Returns:

getInputChannelThreading

public IThreadDispatcherProvider getInputChannelThreading()
Gets threading mode used for input channels.

Returns:

setOutputChannelThreading

public HttpMessagingSystemFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
Sets threading mode for output channels.

Parameters:
outputChannelThreading -
Returns:

getOutputChannelThreading

public IThreadDispatcherProvider getOutputChannelThreading()
Gets threading mode used for output channels.

Returns: