Hazelcast C++ Client
Hazelcast C++ Client Library
hazelcast::client::itopic Class Reference

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 <itopic.h>

+ Inheritance diagram for hazelcast::client::itopic:

Public Member Functions

template<typename E >
boost::future< void > publish (const E &message)
 Publishes the message to all subscribers of this topic. More...
 
boost::future< boost::uuids::uuid > add_message_listener (topic::listener &&listener)
 Subscribe to this topic. More...
 

Static Public Attributes

static constexpr const char * SERVICE_NAME = "hz:impl:topicService"
 

Friends

class spi::ProxyManager
 

Detailed Description

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 39 of file itopic.h.

Member Function Documentation

◆ add_message_listener()

boost::future<boost::uuids::uuid> hazelcast::client::itopic::add_message_listener ( topic::listener &&  listener)
inline

Subscribe to this topic.

When a message is published on this topic, the callback function that was provided to the given Listener object is called.

See also
Listener

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.

Parameters
listener
Returns
registration id.

Definition at line 70 of file itopic.h.

70  {
71  return proxy::ITopicImpl::add_message_listener(
72  std::shared_ptr<impl::BaseEventHandler>(new topic::impl::TopicEventHandlerImpl(get_name(),
73  get_context().get_client_cluster_service(),
74  get_context().get_serialization_service(),
75  std::move(listener))));
76  }

◆ publish()

template<typename E >
boost::future<void> hazelcast::client::itopic::publish ( const E &  message)
inline

Publishes the message to all subscribers of this topic.

Parameters
message

Definition at line 51 of file itopic.h.

51  {
52  return proxy::ITopicImpl::publish(to_data<E>(message));
53  }

The documentation for this class was generated from the following file: