RMQ - RabbitMQ C++ Library
rmqp_consumer.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
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#ifndef INCLUDED_RMQP_CONSUMER
17#define INCLUDED_RMQP_CONSUMER
18
19#include <rmqp_messageguard.h>
20#include <rmqp_topologyupdate.h>
21#include <rmqt_future.h>
22#include <rmqt_message.h>
23#include <rmqt_result.h>
24#include <rmqt_topology.h>
25#include <rmqt_topologyupdate.h>
26
27#include <bsl_functional.h>
28
29namespace BloombergLP {
30namespace rmqp {
31
37
38class Consumer {
39 public:
40 // TYPES
41
48 typedef bsl::function<void(rmqp::MessageGuard&)> ConsumerFunc;
49
50 // CREATORS
52 Consumer();
53
57 virtual rmqt::Future<> cancel() = 0;
58
63 virtual rmqt::Future<> drain() = 0;
64
77 virtual rmqt::Result<>
78 cancelAndDrain(const bsls::TimeInterval& timeout) = 0;
79
84 virtual rmqt::Future<>
85 updateTopologyAsync(const rmqt::TopologyUpdate& topologyUpdate) = 0;
86
87 virtual ~Consumer();
88
89 private:
90 Consumer(const Consumer&) BSLS_KEYWORD_DELETED;
91 Consumer& operator=(const Consumer&) BSLS_KEYWORD_DELETED;
92
93}; // class Consumer
94
95} // namespace rmqp
96} // namespace BloombergLP
97
98#endif // ! INCLUDED_RMQP_CONSUMER
Provide a RabbitMQ Async Consumer API.
Definition: rmqp_consumer.h:38
virtual rmqt::Future updateTopologyAsync(const rmqt::TopologyUpdate &topologyUpdate)=0
Updates topology.
bsl::function< void(rmqp::MessageGuard &)> ConsumerFunc
Callback function used to receive messages.
Definition: rmqp_consumer.h:48
virtual rmqt::Future drain()=0
Can only be called (successfully) once the Consumer has been cancelled, returns a future which resolv...
virtual rmqt::Future cancel()=0
Cancels the consumer, stops new messages flowing in.
Consumer()
Consumer is constructed from the Connection object.
Definition: rmqp_consumer.cpp:21
virtual rmqt::Result cancelAndDrain(const bsls::TimeInterval &timeout)=0
Tells the broker to stop delivering messages to this consumer.
An interface for MessageGuard class.
Definition: rmqp_messageguard.h:39
An async-style Future/Promise object.
Definition: rmqt_future.h:108
A result of an operation.
Definition: rmqt_result.h:37
Definition: rmqt_topologyupdate.h:33