|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IDuplexBrokerClient
Publishes and subscribes messages in the broker.
The broker client is the component which interacts with the broker.
It allows to publish messages via the broker and to subscribe for desired messages in the broker.
The following example shows how to subscribe a message in the broker:
// Create the broker client.
IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory();
IDuplexBrokerClient aBrokerClient = aBrokerFactory.createBrokerClient();
// Register handler to process subscribed messages from the broker.
aBrokerClient.brokerMessageReceived().subscribe(myMessageHandler);
// Attach output channel and be able to communicate with the broker.
// E.g. if the broker communicates via TCP.
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:9843/");
aBrokerClient.attachDuplexOutputChannel(anOutputChannel);
// Now when the connection with the broker is establish so we can subscribe for
// messages in the broker.
// After this call whenever somebody sends the message type 'MyMessageType' into the broker
// the broker will forward it to this broker client and the message handler
// myMessageHandler will be called.
aBrokerClient.subscribe("MyMessageType");
// Create the broker client.
IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory();
IDuplexBrokerClient aBrokerClient = aBrokerFactory.createBrokerClient();
// Attach output channel and be able to communicate with the broker.
// E.g. if the broker communicates via TCP.
IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
IDuplexOutputChannel anOutputChannel = aMessaging.createDuplexOutputChannel("tcp://127.0.0.1:9843/");
aBrokerClient.attachDuplexOutputChannel(anOutputChannel);
// Now when the connection with the broker is establish so we can publish the message.
// Note: the broker will receive the message and will forward it to everybody who is subscribed for MyMessageType.
aBrokerClient.sendMessage("MyMessageType", "Hello world.");
Method Summary | |
---|---|
Event<BrokerMessageReceivedEventArgs> |
brokerMessageReceived()
Event raised when a subscribed message type is received from the broker. |
Event<DuplexChannelEventArgs> |
connectionClosed()
Event raised when the connection with the service was closed. |
Event<DuplexChannelEventArgs> |
connectionOpened()
Event raised when the connection with the service was open. |
void |
sendMessage(java.lang.String messageType,
java.lang.Object serializedMessage)
Publishes the message via the broker. |
void |
subscribe(java.lang.String messageType)
Subscribes for the message type. |
void |
subscribe(java.lang.String[] messageType)
Subscribes for list of message types. |
void |
unsubscribe()
Unsubscribe all messages. |
void |
unsubscribe(java.lang.String messageType)
Unsubscribes from the specified message type. |
void |
unsubscribe(java.lang.String[] messageTypes)
Unsubscribes from specified message types. |
Methods inherited from interface eneter.messaging.infrastructure.attachable.IAttachableDuplexOutputChannel |
---|
attachDuplexOutputChannel, detachDuplexOutputChannel, getAttachedDuplexOutputChannel, isDuplexOutputChannelAttached |
Method Detail |
---|
Event<DuplexChannelEventArgs> connectionOpened()
Event<DuplexChannelEventArgs> connectionClosed()
Event<BrokerMessageReceivedEventArgs> brokerMessageReceived()
void sendMessage(java.lang.String messageType, java.lang.Object serializedMessage) throws java.lang.Exception
messageType
- event identifierserializedMessage
- message content.
java.lang.Exception
void subscribe(java.lang.String messageType) throws java.lang.Exception
messageType
- identifies the type of the message which shall be subscribed.
java.lang.Exception
void subscribe(java.lang.String[] messageType) throws java.lang.Exception
messageType
- list of message types which shall be subscribed.
java.lang.Exception
void unsubscribe(java.lang.String messageType) throws java.lang.Exception
messageType
- message type the client does not want to receive anymore.
java.lang.Exception
void unsubscribe(java.lang.String[] messageTypes) throws java.lang.Exception
messageTypes
- list of message types the client does not want to receive anymore.
java.lang.Exception
void unsubscribe() throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |