|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteneter.messaging.nodes.broker.DuplexBrokerFactory
public class DuplexBrokerFactory
Creates broker and broker client.
The broker is the component for publish-subscribe scenarios. It maintains the list of subscribers.
When it receives a notification message it forwards it to subscribed clients.
IDuplexBrokerClient can publish messages via the broker
and also can subscribe for desired messages.
The example shows how to create and use the broker via TCP.
// Create Tcp based messaging.
IMessagingSystemFactory aMessagingFactory = new TcpMessagingSystemFactory();
// Create duplex input channel listening to messages.
IDuplexInputChannel anInputChannel = aMessagingFactory.createDuplexInputChannel("tcp://127.0.0.1:7980/");
// Create the factory for the broker.
IDuplexBrokerFactory aBrokerFactory = new DuplexBrokerFactory();
// Create the broker.
IDuplexBroker aBroker = aBrokerFactory.createBroker();
// Attach the Tcp duplex input channel to the broker and start listening.
aBroker.attachDuplexInputChannel(anInputChannel);
// Create Tcp based messaging for the silverlight client.
IMessagingSystemFactory aTcpMessagingFactory = new TcpMessagingSystemFactory();
// Create duplex output channel to send and receive messages.
myOutputChannel = aTcpMessagingFactory.createDuplexOutputChannel("tcp://127.0.0.1:7980/");
// Create the broker client
IDuplexBrokerFactory aDuplexBrokerFactory = new DuplexBrokerFactory();
myBrokerClient = aDuplexBrokerFactory.createBrokerClient();
// Handler to process notification messages.
myBrokerClient.brokerMessageReceived().subscribe(myNotifyMessageReceived);
// Attach the channel to the broker client to be able to send and receive messages.
myBrokerClient.attachDuplexOutputChannel(myOutputChannel);
// Subscribe in broker to receive chat messages.
myBrokerClient.subscribe("MyChatMessageType");
...
// Send message to the broker. The broker will then forward it to all subscribers.
XmlStringSerializer anXmlSerializer = new XmlStringSerializer();
Object aSerializedChatMessage = anXmlSerializer.Serialize(aChatMessage, ChatMessage.class);
myBrokerClient.sendMessage("MyChatMessageType", aSerializedChatMessage);
Constructor Summary | |
---|---|
DuplexBrokerFactory()
Constructs the broker factory with optimized custom serializer. |
|
DuplexBrokerFactory(ISerializer serializer)
Constructs the broker factory with specified serializer. |
Method Summary | |
---|---|
IDuplexBroker |
createBroker()
Creates the broker. |
IDuplexBrokerClient |
createBrokerClient()
Creates the broker client. |
AuthorizeBrokerRequestCallback |
getBrokerRequestAuthorizer()
Gets callback for authorizing request messages received from DuplexBrokerClient. |
boolean |
getIsPublisherNotified()
Gets the flag whether the publisher which sent a message shall be notified in case it is subscribed to the same message. |
ISerializer |
getSerializer()
Returns the serializer which is used to serialize/deserialize BrokerMessate . |
GetSerializerCallback |
getSerializerProvider()
Gets callback for retrieving serializer based on response receiver id. |
DuplexBrokerFactory |
setBrokerRequestAuthorizer(AuthorizeBrokerRequestCallback authorizeCallaback)
Sets callback for authorizing request messages received from DuplexBrokerClient. |
DuplexBrokerFactory |
setIsPublisherNotified(boolean isPublisherNotified)
Sets the flag whether the publisher which sent a message shall be notified in case it is subscribed to the same message. |
DuplexBrokerFactory |
setSerializer(ISerializer serializer)
Sets the serializer to serialize/deserialize BrokerMessage . |
DuplexBrokerFactory |
setSerializerProvider(GetSerializerCallback serializerProvider)
Sets callback for retrieving serializer based on response receiver id. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DuplexBrokerFactory()
public DuplexBrokerFactory(ISerializer serializer)
serializer
- serializer used by the brokerMethod Detail |
---|
public IDuplexBrokerClient createBrokerClient() throws java.lang.Exception
IDuplexBrokerFactory
createBrokerClient
in interface IDuplexBrokerFactory
java.lang.Exception
public IDuplexBroker createBroker() throws java.lang.Exception
IDuplexBrokerFactory
createBroker
in interface IDuplexBrokerFactory
java.lang.Exception
public DuplexBrokerFactory setSerializer(ISerializer serializer)
BrokerMessage
.
BrokerMessage
is used for the communication with the broker.
serializer
- serializer
public ISerializer getSerializer()
BrokerMessate
.
public GetSerializerCallback getSerializerProvider()
public DuplexBrokerFactory setSerializerProvider(GetSerializerCallback serializerProvider)
serializerProvider
-
public AuthorizeBrokerRequestCallback getBrokerRequestAuthorizer()
public DuplexBrokerFactory setBrokerRequestAuthorizer(AuthorizeBrokerRequestCallback authorizeCallaback)
authorizeCallaback
-
public DuplexBrokerFactory setIsPublisherNotified(boolean isPublisherNotified)
isPublisherNotified
- true if the DuplexBrokerClient which sent the message shall be notified too.
public boolean getIsPublisherNotified()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |