RMQ - RabbitMQ C++ Library
rmqp_producer.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_producer.h
17#ifndef INCLUDED_RMQP_PRODUCER
18#define INCLUDED_RMQP_PRODUCER
19
20#include <rmqt_queue.h>
21
22#include <rmqp_messagetransformer.h>
23#include <rmqp_topologyupdate.h>
24#include <rmqt_confirmresponse.h>
25#include <rmqt_exchange.h>
26#include <rmqt_message.h>
27#include <rmqt_result.h>
28#include <rmqt_topology.h>
29
30#include <bsls_timeinterval.h>
31
32#include <bsl_functional.h>
33#include <bsl_memory.h>
34#include <bsl_string.h>
35#include <rmqt_future.h>
36
37namespace BloombergLP {
38namespace rmqp {
39
46class Producer {
47 public:
48 // TYPES
51 SENDING,
52 DUPLICATE,
53 TIMEOUT,
54 INFLIGHT_LIMIT,
55 TRANSFORM_ERROR
56 };
57
68 typedef bsl::function<void(const rmqt::Message&,
69 const bsl::string& routingKey,
72
73 // CREATORS
74 virtual ~Producer();
75
76 // MANIPULATORS
77
81 virtual void addTransformer(
82 const bsl::shared_ptr<rmqp::MessageTransformer>& transformer) = 0;
83
118 virtual SendStatus
119 send(const rmqt::Message& message,
120 const bsl::string& routingKey,
121 const rmqp::Producer::ConfirmationCallback& confirmCallback,
122 const bsls::TimeInterval& timeout) = 0;
123
166 virtual SendStatus
167 send(const rmqt::Message& message,
168 const bsl::string& routingKey,
169 rmqt::Mandatory::Value mandatoryFlag,
170 const rmqp::Producer::ConfirmationCallback& confirmCallback,
171 const bsls::TimeInterval& timeout) = 0;
172
206 virtual SendStatus
207 trySend(const rmqt::Message& message,
208 const bsl::string& routingKey,
209 const rmqp::Producer::ConfirmationCallback& confirmCallback) = 0;
210
220 virtual rmqt::Result<>
221 waitForConfirms(const bsls::TimeInterval& timeout) = 0;
222
227 virtual rmqt::Future<>
228 updateTopologyAsync(const rmqt::TopologyUpdate& topologyUpdate) = 0;
229
230 protected:
231 Producer();
232
233 private:
234 Producer(const Producer&) BSLS_KEYWORD_DELETED;
235 Producer& operator=(const Producer&) BSLS_KEYWORD_DELETED;
236
237}; // class Producer
238
239} // namespace rmqp
240} // namespace BloombergLP
241
242#endif // ! INCLUDED_RMQP_PRODUCER
RabbitMQ Producer API for publishing to a specific Exchange.
Definition: rmqp_producer.h:46
virtual SendStatus send(const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout)=0
Send a message with the given routingKey to the exchange targeted by the producer.
virtual rmqt::Result waitForConfirms(const bsls::TimeInterval &timeout)=0
Wait for all outstanding publisher confirms to arrive.
virtual void addTransformer(const bsl::shared_ptr< rmqp::MessageTransformer > &transformer)=0
Adds a transformation function to be run on all messages.
bsl::function< void(const rmqt::Message &, const bsl::string &routingKey, const rmqt::ConfirmResponse &)> ConfirmationCallback
Invoked on receipt of message confirmation.
Definition: rmqp_producer.h:71
virtual SendStatus send(const rmqt::Message &message, const bsl::string &routingKey, rmqt::Mandatory::Value mandatoryFlag, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout)=0
Send a message with the given routingKey to the exchange targeted by the producer.
virtual SendStatus trySend(const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback)=0
Send a message with the given routingKey to the exchange targeted by the producer.
Definition: rmqa_producer.cpp:55
SendStatus
Possible results of rmqp::Producer::send.
Definition: rmqp_producer.h:50
virtual rmqt::Future updateTopologyAsync(const rmqt::TopologyUpdate &topologyUpdate)=0
Updates topology.
An AMQP publisher confirm response.
Definition: rmqt_confirmresponse.h:33
An async-style Future/Promise object.
Definition: rmqt_future.h:108
An AMQP content message.
Definition: rmqt_message.h:43
A result of an operation.
Definition: rmqt_result.h:37
Definition: rmqt_topologyupdate.h:33