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
73 typedef bsl::function<void(const rmqt::Message&,
74 const bsl::string& routingKey,
77
78 // CREATORS
79 virtual ~Producer();
80
81 // MANIPULATORS
82
86 virtual void addTransformer(
87 const bsl::shared_ptr<rmqp::MessageTransformer>& transformer) = 0;
88
123 virtual SendStatus
124 send(const rmqt::Message& message,
125 const bsl::string& routingKey,
126 const rmqp::Producer::ConfirmationCallback& confirmCallback,
127 const bsls::TimeInterval& timeout) = 0;
128
171 virtual SendStatus
172 send(const rmqt::Message& message,
173 const bsl::string& routingKey,
174 rmqt::Mandatory::Value mandatoryFlag,
175 const rmqp::Producer::ConfirmationCallback& confirmCallback,
176 const bsls::TimeInterval& timeout) = 0;
177
211 virtual SendStatus
212 trySend(const rmqt::Message& message,
213 const bsl::string& routingKey,
214 const rmqp::Producer::ConfirmationCallback& confirmCallback) = 0;
215
230 virtual rmqt::Result<>
231 waitForConfirms(const bsls::TimeInterval& timeout) = 0;
232
237 virtual rmqt::Future<>
238 updateTopologyAsync(const rmqt::TopologyUpdate& topologyUpdate) = 0;
239
240 protected:
241 Producer();
242
243 private:
244 Producer(const Producer&) BSLS_KEYWORD_DELETED;
245 Producer& operator=(const Producer&) BSLS_KEYWORD_DELETED;
246
247}; // class Producer
248
249} // namespace rmqp
250} // namespace BloombergLP
251
252#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:76
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