AMQP::Reliable::publish() now takes std::string_view + added extra constructor to AMQP::Envelope

This commit is contained in:
Emiel Bruijntjes 2023-03-26 18:31:55 +02:00
parent 7d3e79057c
commit 48b9f05677
2 changed files with 7 additions and 6 deletions

View File

@ -4,7 +4,7 @@
* When you send or receive a message to the rabbitMQ server, it is encapsulated
* in an envelope that contains additional meta information as well.
*
* @copyright 2014 - 2020 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/
/**
@ -53,6 +53,7 @@ public:
* @param size
*/
Envelope(const char *body, uint64_t size) : MetaData(), _body(body), _bodySize(size) {}
Envelope(const char *body) : Envelope(body, strlen(body)) {}
/**
* Read envelope frmo an input-buffer

View File

@ -9,7 +9,7 @@
* throttling at the same time.
*
* @author Michael van der Werve <michael.vanderwerve@mailerq.com>
* @copyright 2020 - 2022 Copernica BV
* @copyright 2020 - 2023 Copernica BV
*/
/**
@ -239,9 +239,9 @@ public:
* @param flags optional flags
* @return bool
*/
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const std::string &message, int flags = 0) { return publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const char *message, size_t size, int flags = 0) { return publish(exchange, routingKey, Envelope(message, size), flags); }
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const char *message, int flags = 0) { return publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const std::string_view &message, int flags = 0) { return publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, size_t size, int flags = 0) { return publish(exchange, routingKey, Envelope(message, size), flags); }
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, int flags = 0) { return publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
/**
* Publish a message to an exchange. See amqpcpp/channel.h for more details on the flags.
@ -254,7 +254,7 @@ public:
* @param size size of the message
* @param flags optional flags
*/
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags = 0)
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags = 0)
{
// publish the entire thing, and remember if it failed at any point
uint64_t tag = BASE::publish(exchange, routingKey, envelope, flags);