2014-04-08 20:42:07 +08:00
|
|
|
/**
|
|
|
|
|
* Callbacks.h
|
|
|
|
|
*
|
|
|
|
|
* Class storing deferred callbacks of different type.
|
|
|
|
|
*
|
2018-03-02 04:12:53 +08:00
|
|
|
* @copyright 2014 - 2018 Copernica BV
|
2014-04-08 20:42:07 +08:00
|
|
|
*/
|
|
|
|
|
|
2016-04-06 22:49:39 +08:00
|
|
|
/**
|
|
|
|
|
* Include guard
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
|
|
|
|
* Dependencies
|
|
|
|
|
*/
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
2014-04-08 20:42:07 +08:00
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
|
|
|
|
* Forward declarations
|
|
|
|
|
*/
|
|
|
|
|
class Message;
|
|
|
|
|
class MetaData;
|
|
|
|
|
|
2014-04-08 20:42:07 +08:00
|
|
|
/**
|
2018-03-02 04:12:53 +08:00
|
|
|
* Generic callbacks that are used by many deferred objects
|
|
|
|
|
*/
|
|
|
|
|
using SuccessCallback = std::function<void()>;
|
|
|
|
|
using ErrorCallback = std::function<void(const char *message)>;
|
|
|
|
|
using FinalizeCallback = std::function<void()>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Declaring and deleting a queue
|
|
|
|
|
*/
|
|
|
|
|
using QueueCallback = std::function<void(const std::string &name, uint32_t messagecount, uint32_t consumercount)>;
|
|
|
|
|
using DeleteCallback = std::function<void(uint32_t deletedmessages)>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* When retrieving the size of a queue in some way
|
|
|
|
|
*/
|
|
|
|
|
using EmptyCallback = std::function<void()>;
|
2018-04-23 15:30:37 +08:00
|
|
|
using CountCallback = std::function<void(uint32_t messagecount)>;
|
|
|
|
|
using SizeCallback = std::function<void(uint64_t messagesize)>;
|
2018-03-02 04:12:53 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starting and stopping a consumer
|
|
|
|
|
*/
|
|
|
|
|
using ConsumeCallback = std::function<void(const std::string &consumer)>;
|
|
|
|
|
using CancelCallback = std::function<void(const std::string &consumer)>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Receiving messages, either via consume(), get() or as returned messages
|
|
|
|
|
* The following methods receive the returned message in multiple parts
|
|
|
|
|
*/
|
|
|
|
|
using StartCallback = std::function<void(const std::string &exchange, const std::string &routingkey)>;
|
|
|
|
|
using HeaderCallback = std::function<void(const MetaData &metaData)>;
|
|
|
|
|
using DataCallback = std::function<void(const char *data, size_t size)>;
|
|
|
|
|
using DeliveredCallback = std::function<void(uint64_t deliveryTag, bool redelivered)>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For returned messages amqp-cpp first calls a return-callback before the start,
|
|
|
|
|
* header and data callbacks are called. Instead of the deliver-callback, a
|
|
|
|
|
* returned-callback is called.
|
|
|
|
|
*/
|
|
|
|
|
using ReturnCallback = std::function<void(int16_t code, const std::string &message)>;
|
|
|
|
|
using ReturnedCallback = std::function<void()>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If you do not want to merge all data into a single string, you can als
|
|
|
|
|
* implement callbacks that return the collected message.
|
|
|
|
|
*/
|
|
|
|
|
using MessageCallback = std::function<void(const Message &message, uint64_t deliveryTag, bool redelivered)>;
|
|
|
|
|
using BounceCallback = std::function<void(const Message &message, int16_t code, const std::string &description)>;
|
2014-04-08 20:42:07 +08:00
|
|
|
|
2018-04-10 16:30:01 +08:00
|
|
|
/**
|
|
|
|
|
* When using publisher confirms, AckCallback is called when server confirms that message is received
|
|
|
|
|
* and processed. NackCallback is called otherwise.
|
|
|
|
|
*/
|
|
|
|
|
using AckCallback = std::function<void(uint64_t deliveryTag, bool multiple)>;
|
|
|
|
|
using NackCallback = std::function<void(uint64_t deliveryTag, bool multiple, bool requeue)>;
|
|
|
|
|
|
2020-10-07 17:49:38 +08:00
|
|
|
/**
|
|
|
|
|
* When using a confirm wrapped channel, these callbacks are called when a message is acknowledged/nacked.
|
|
|
|
|
*/
|
|
|
|
|
using PublishAckCallback = std::function<void()>;
|
|
|
|
|
using PublishNackCallback = std::function<void()>;
|
2020-10-12 18:02:04 +08:00
|
|
|
using PublishLostCallback = std::function<void()>;
|
2020-10-07 17:49:38 +08:00
|
|
|
|
2014-04-08 20:42:07 +08:00
|
|
|
/**
|
|
|
|
|
* End namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|