RMQ - RabbitMQ C++ Library
rmqa_vhost.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// rmqa_vhost.h
17#ifndef INCLUDED_RMQA_VHOST
18#define INCLUDED_RMQA_VHOST
19
20#include <rmqa_topology.h>
21#include <rmqp_connection.h>
22#include <rmqp_consumer.h>
23#include <rmqp_topology.h>
24#include <rmqt_consumerconfig.h>
25#include <rmqt_credentials.h>
26#include <rmqt_endpoint.h>
27#include <rmqt_future.h>
28#include <rmqt_properties.h>
29#include <rmqt_queue.h>
30#include <rmqt_result.h>
31
32#include <bdlmt_threadpool.h>
33
34#include <bslma_managedptr.h>
35#include <bsls_timeinterval.h>
36
37#include <bsl_memory.h>
38#include <bsl_string.h>
39
40namespace BloombergLP {
41namespace rmqa {
42
43class Producer;
44class Consumer;
45
51
52class VHost {
53 public:
54 // CREATORS
57 explicit VHost(bslma::ManagedPtr<rmqp::Connection> impl);
58
60 virtual ~VHost();
61
62 // MANIPULATORS
81 rmqt::ExchangeHandle exchange,
82 uint16_t maxOutstandingConfirms);
83
100 createConsumer(const rmqp::Topology& topology,
101 rmqt::QueueHandle queue,
102 const rmqp::Consumer::ConsumerFunc& onMessage,
104
126 const rmqp::Topology& topology,
127 rmqt::QueueHandle queue,
128 const rmqp::Consumer::ConsumerFunc& onMessage,
129 const bsl::string& consumerTag,
130 uint16_t prefetchCount = rmqt::ConsumerConfig::s_defaultPrefetchCount);
131
134 void close();
135
137 static bsl::string generateConsumerTag();
138
139#ifdef USES_LIBRMQ_EXPERIMENTAL_FEATURES
161 deleteQueue(const bsl::string& name,
162 rmqt::QueueUnused::Value ifUnused,
163 rmqt::QueueEmpty::Value ifEmpty,
164 const bsls::TimeInterval& timeout = bsls::TimeInterval(0));
165
168 rmqt::Future<Producer> createProducerAsync(const rmqp::Topology& topology,
169 rmqt::ExchangeHandle exchange,
170 uint16_t maxOutstandingConfirms);
171
172 rmqt::Future<Consumer> createConsumerAsync(
173 const rmqp::Topology& topology,
174 rmqt::QueueHandle queue,
175 const rmqp::Consumer::ConsumerFunc& onMessage,
177
178 // DEPRECATED
179 rmqt::Future<Consumer> createConsumerAsync(
180 const rmqp::Topology& topology,
181 rmqt::QueueHandle queue,
182 const rmqp::Consumer::ConsumerFunc& onMessage,
183 const bsl::string& consumerTag,
184 uint16_t prefetchCount = rmqt::ConsumerConfig::s_defaultPrefetchCount);
185#endif
186
187 private:
188 VHost(const VHost&) BSLS_KEYWORD_DELETED;
189 VHost& operator=(const VHost&) BSLS_KEYWORD_DELETED;
190
191 private:
192 bslma::ManagedPtr<rmqp::Connection> d_impl;
193};
194
195} // namespace rmqa
196} // namespace BloombergLP
197
198#endif // ! INCLUDED_RMQA_VHOST
A RabbitMQ VHost object.
Definition: rmqa_vhost.h:52
rmqt::Result< Consumer > createConsumer(const rmqp::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &onMessage, const rmqt::ConsumerConfig &config=rmqt::ConsumerConfig())
Create an asynchronous consumer using the provided Topology.
Definition: rmqa_vhost.cpp:64
void close()
Close the connection to the broker. The connection will not reconnect after this call.
Definition: rmqa_vhost.cpp:46
rmqt::Result< Producer > createProducer(const rmqp::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms)
Create a producer using the provided Topology. This method starts the process of declaring the topolo...
Definition: rmqa_vhost.cpp:53
static bsl::string generateConsumerTag()
Definition: rmqa_vhost.cpp:48
VHost(bslma::ManagedPtr< rmqp::Connection > impl)
Definition: rmqa_vhost.cpp:41
virtual ~VHost()
The RabbitMQ connection will be disconnected on this call.
Definition: rmqa_vhost.cpp:35
bsl::function< void(rmqp::MessageGuard &)> ConsumerFunc
Callback function used to receive messages.
Definition: rmqp_consumer.h:48
An interface providing a manipulatable RabbitMQ topology structure.
Definition: rmqp_topology.h:39
Class for passing arguments to Consumer.
Definition: rmqt_consumerconfig.h:42
An async-style Future/Promise object.
Definition: rmqt_future.h:108
A result of an operation.
Definition: rmqt_result.h:37