RMQ - RabbitMQ C++ Library
rmqp_connection.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// rmqp_connection.h
17#ifndef INCLUDED_RMQP_CONNECTION
18#define INCLUDED_RMQP_CONNECTION
19
20#include <rmqp_consumer.h>
21#include <rmqp_producer.h>
22#include <rmqt_consumerconfig.h>
23
24#include <rmqt_future.h>
25#include <rmqt_result.h>
26
27#include <bsl_string.h>
28#include <bsls_timeinterval.h>
29
30//@PURPOSE: Provide a RabbitMQ Connection API
31//
32//@CLASSES:
33// rmqp::Connection: a RabbitMQ Connection API object
34
35namespace BloombergLP {
36namespace rmqp {
37
41
43 public:
44 // TYPES
45 typedef enum { SUCCESS = 0, FAIL } ReturnCode;
46
47 Connection();
48 virtual ~Connection();
49
50 // MANIPULATORS
66 rmqt::ExchangeHandle exchange,
67 uint16_t maxOutstandingConfirms) = 0;
68
85 rmqt::QueueHandle queue,
86 const rmqp::Consumer::ConsumerFunc& onMessage,
87 const rmqt::ConsumerConfig& consumerConfig) = 0;
88
93 virtual void close() = 0;
94
96 createProducerAsync(const rmqt::Topology& topology,
97 rmqt::ExchangeHandle exchange,
98 uint16_t maxOutstandingConfirms) = 0;
99
101 createConsumerAsync(const rmqt::Topology& topology,
102 rmqt::QueueHandle queue,
103 const rmqp::Consumer::ConsumerFunc& onMessage,
104 const rmqt::ConsumerConfig& consumerConfig) = 0;
105
106 // DEPRECATED
117 createConsumer(const rmqt::Topology& topology,
118 rmqt::QueueHandle queue,
119 const rmqp::Consumer::ConsumerFunc& messageConsumer,
120 const bsl::string& consumerTag,
121 uint16_t prefetchCount);
122
124 createConsumerAsync(const rmqt::Topology& topology,
125 rmqt::QueueHandle queue,
126 const rmqp::Consumer::ConsumerFunc& messageConsumer,
127 const bsl::string& consumerTag,
128 uint16_t prefetchCount);
129
130}; // class Connection
131
132} // namespace rmqp
133} // namespace BloombergLP
134
135#endif // ! INCLUDED_RMQP_CONNECTION
Provide a RabbitMQ Connection API.
Definition: rmqp_connection.h:42
virtual void close()=0
Flush all data pending and then close the connection. Close the connection and invalidates all consum...
virtual rmqt::Result< Producer > createProducer(const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms)=0
virtual rmqt::Result< rmqp::Consumer > createConsumer(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &onMessage, const rmqt::ConsumerConfig &consumerConfig)=0
Create an asynchronous consumer using the provided Topology.
bsl::function< void(rmqp::MessageGuard &)> ConsumerFunc
Callback function used to receive messages.
Definition: rmqp_consumer.h:48
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
Definition: rmqt_topology.h:32