public class TcpMessagingSystemFactory extends java.lang.Object implements IMessagingSystemFactory
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
// Create duplex input channel which can receive messages on the address 127.0.0.1 and the port 9043
// and which can send response messages to connected output channels.
IDuplexInputChannel anInputChannel = aMessaging.createDuplexInputChannel("tcp://127.0.0.1:9043/");
// Subscribe to handle messages.
anInputChannel.messageReceived().subscribe(myOnMessageReceived);
// Start listening and be able to receive messages.
anInputChannel.startListening();
...
// Stop listening.
anInputChannel.stopListeing();
Creating output channel for TCP messaging.
// Create duplex output channel which can send messages to 127.0.0.1 on the port 9043 and
// receive response messages.
IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:9043/");
// Subscribe to handle messages.
anOutputChannel.responseMessageReceived().subscribe(myOnMessageReceived);
// Open connection to the input channel which listens to tcp://127.0.0.1:9043/.
anOutputChannel.openConnection();
...
// Close connection.
anOutputChannel.closeConnection();
Constructor and Description |
---|
TcpMessagingSystemFactory()
Constructs the TCP messaging factory.
|
TcpMessagingSystemFactory(IProtocolFormatter protocolFormatter)
Constructs the TCP messaging factory.
|
Modifier and Type | Method and Description |
---|---|
IDuplexInputChannel |
createDuplexInputChannel(java.lang.String channelId)
Creates the duplex input channel which can receive and send messages to the duplex output channel using TCP.
|
IDuplexOutputChannel |
createDuplexOutputChannel(java.lang.String channelId)
Creates duplex output channel which can send and receive messages from the duplex input channel using TCP.
|
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 TCP.
|
static java.lang.String[] |
getAvailableIpAddresses()
Returns IP addresses assigned to the device which can be used for the listening.
|
IClientSecurityFactory |
getClientSecurity()
Gets the factory that is used for creation of client sockets.
|
IThreadDispatcherProvider |
getInputChannelThreading()
Gets threading mode used for input channels.
|
IThreadDispatcherProvider |
getOutputChannelThreading()
Gets threading mode used for output channels.
|
IServerSecurityFactory |
getServerSecurity()
Gets the factory that is used for creation of server sockets.
|
TcpMessagingSystemFactory |
setClientSecurity(IClientSecurityFactory clientSecurityFactory)
Sets the factory that will be used for creation of secured client socket.
|
TcpMessagingSystemFactory |
setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
Sets threading mode for input channels.
|
TcpMessagingSystemFactory |
setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
Sets threading mode for output channels.
|
TcpMessagingSystemFactory |
setServerSecurity(IServerSecurityFactory serverSecurityFactory)
Sets the factory that will be used for creation of server sockets.
|
public TcpMessagingSystemFactory()
public TcpMessagingSystemFactory(IProtocolFormatter protocolFormatter)
protocolFormatter
- formats OpenConnection, CloseConnection and Message messages between channels.public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId) throws java.lang.Exception
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory(); IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:8765/");
createDuplexOutputChannel
in interface IMessagingSystemFactory
channelId
- Identifies the receiving duplex input channel. The channel id must be a valid URI address e.g. tcp://127.0.0.1:8090/java.lang.Exception
public IDuplexOutputChannel createDuplexOutputChannel(java.lang.String channelId, java.lang.String responseReceiverId) throws java.lang.Exception
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:8765/", "MyUniqueClientId_1");
createDuplexOutputChannel
in interface IMessagingSystemFactory
channelId
- Identifies the input channel which shall be connected. The channel id must be a valid URI address e.g. tcp://127.0.0.1:8090/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
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
IDuplexInputChannel anInputChannel = aMessaging.createDuplexInputChannel("tcp://127.0.0.1:9876/");
createDuplexInputChannel
in interface IMessagingSystemFactory
channelId
- The IP address and port which shall be used for listening.
The channel id must be a valid URI address (e.g. tcp://127.0.0.1:8090/).java.lang.Exception
public static java.lang.String[] getAvailableIpAddresses() throws java.net.SocketException
java.net.SocketException
public TcpMessagingSystemFactory setServerSecurity(IServerSecurityFactory serverSecurityFactory)
serverSecurityFactory
- public IServerSecurityFactory getServerSecurity()
public TcpMessagingSystemFactory setClientSecurity(IClientSecurityFactory clientSecurityFactory)
clientSecurityFactory
- public IClientSecurityFactory getClientSecurity()
public TcpMessagingSystemFactory setInputChannelThreading(IThreadDispatcherProvider inputChannelThreading)
inputChannelThreading
- threading modelpublic IThreadDispatcherProvider getInputChannelThreading()
public TcpMessagingSystemFactory setOutputChannelThreading(IThreadDispatcherProvider outputChannelThreading)
outputChannelThreading
- public IThreadDispatcherProvider getOutputChannelThreading()