|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ITopic<E>
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subscribers, which is also known as a publish/subscribe (pub/sub) messaging model. Publish and subscriptions are cluster-wide. When a member subscribes for a topic, it is actually registering for messages published by any member in the cluster, including the new members joined after you added the listener.
Messages are ordered, meaning that listeners(subscribers) will process the messages in the order they are actually published. If cluster member M publishes messages m1, m2, m3...mn to a topic T, then Hazelcast makes sure that all of the subscribers of topic T will receive and process m1, m2, m3...mn in order. Since Hazelcast 3.5 it is possible to have reliable topics. Normally all topics rely on the a shared eventing system and shared threads. With Hazelcast 3.5 it is possible to configure a topic to be reliable and to gets its ownRingbuffer
to store events and to gets its own executor to process events. The events
in the rinbuffer are replicated, so they won't get lost when a node goes down.
Method Summary | |
---|---|
String |
addMessageListener(MessageListener<E> listener)
Subscribes to this topic. |
LocalTopicStats |
getLocalTopicStats()
Returns statistics about this topic, like total number of publishes/receives |
String |
getName()
Returns the name of this ITopic instance |
void |
publish(E message)
Publishes the message to all subscribers of this topic |
boolean |
removeMessageListener(String registrationId)
Stops receiving messages for the given message listener. |
Methods inherited from interface com.hazelcast.core.DistributedObject |
---|
destroy, getId, getPartitionKey, getServiceName |
Method Detail |
---|
String getName()
getName
in interface DistributedObject
void publish(E message)
message
- the message to publish to all subscribers of this topic
TopicOverloadException
- if the consumer is too slow. Only works in combination with
reliable topic.String addMessageListener(MessageListener<E> listener)
listener
- the MessageListener to add.
NullPointerException
- if listener is null.boolean removeMessageListener(String registrationId)
registrationId
- Id of listener registration.
LocalTopicStats getLocalTopicStats()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |