Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
itopic.h
1/*
2 * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "hazelcast/client/proxy/ITopicImpl.h"
19#include "hazelcast/client/topic/impl/TopicEventHandlerImpl.h"
20
21namespace hazelcast {
22namespace client {
23namespace topic {
24class listener;
25}
26
42class itopic : public proxy::ITopicImpl
43{
44 friend class spi::ProxyManager;
45
46public:
47 static constexpr const char* SERVICE_NAME = "hz:impl:topicService";
48
54 template<typename E>
55 boost::future<void> publish(const E& message)
56 {
57 return proxy::ITopicImpl::publish(to_data<E>(message));
58 }
59
75 boost::future<boost::uuids::uuid> add_message_listener(
76 topic::listener&& listener)
77 {
78 return proxy::ITopicImpl::add_message_listener(
79 std::shared_ptr<impl::BaseEventHandler>(
80 new topic::impl::TopicEventHandlerImpl(
81 get_name(),
82 get_context().get_logger(),
83 get_context().get_client_cluster_service(),
84 get_context().get_serialization_service(),
85 std::move(listener))));
86 }
87
88private:
89 itopic(const std::string& instance_name, spi::ClientContext* context)
90 : proxy::ITopicImpl(instance_name, context)
91 {}
92};
93} // namespace client
94} // namespace hazelcast
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subs...
Definition itopic.h:43
boost::future< void > publish(const E &message)
Publishes the message to all subscribers of this topic.
Definition itopic.h:55
boost::future< boost::uuids::uuid > add_message_listener(topic::listener &&listener)
Subscribe to this topic.
Definition itopic.h:75
Listen to messages from an ITopic.
Definition listener.h:42