![]() |
Hazelcast C++ Client
Hazelcast C++ Client Library
|
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subscribers which is also known as publish/subscribe (pub/sub) messaging model. More...
#include <reliable_topic.h>
Public Member Functions | |
template<typename E > | |
boost::future< void > | publish (const E &message) |
Publishes the message to all subscribers of this topic Current implementation only supports DISCARD_OLDEST policy as in Java client. More... | |
template<typename Listener > | |
std::string | add_message_listener (Listener &&listener) |
Subscribes to this topic. More... | |
bool | remove_message_listener (const std::string ®istration_id) |
Stops receiving messages for the given message listener. More... | |
Static Public Attributes | |
static constexpr const char * | SERVICE_NAME = "hz:impl:reliableTopicService" |
Protected Member Functions | |
void | on_shutdown () override |
void | on_destroy () override |
void | post_destroy () override |
Friends | |
class | spi::ProxyManager |
class | hazelcast_client |
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subscribers which is also known as 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, 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.
Definition at line 49 of file reliable_topic.h.
|
inline |
Subscribes to this topic.
When someone publishes a message on this topic. onMessage() function of the given MessageListener is called. More than one message listener can be added on one instance.
Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.
Warning 2: Do not make a call to hazelcast. It can cause deadlock.
Warning 3: Make sure that the MessageListener object is not destroyed until the removeListener is called, since the library will use the MessageListener reference to deliver incoming messages.
listener | the MessageListener to add. |
Definition at line 87 of file reliable_topic.h.
|
inline |
Publishes the message to all subscribers of this topic Current implementation only supports DISCARD_OLDEST policy as in Java client.
The other policies will be available when async API is completed. Using this policy the oldest item is overwritten no matter it is not old enough to retire.
message | The message to be published |
Definition at line 64 of file reliable_topic.h.
bool hazelcast::client::reliable_topic::remove_message_listener | ( | const std::string & | registration_id | ) |
Stops receiving messages for the given message listener.
If the given listener already removed, this method does nothing.
registrationId | Id of listener registration. |