File: callbacks.h

package info (click to toggle)
amqp-cpp 4.3.27-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,384 kB
  • sloc: cpp: 10,021; ansic: 191; makefile: 95
file content (98 lines) | stat: -rw-r--r-- 3,273 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
 *  Callbacks.h
 *
 *  Class storing deferred callbacks of different type.
 *
 *  @copyright 2014 - 2018 Copernica BV
 */

/**
 *  Include guard
 */
#pragma once

/**
 *  Dependencies
 */
#include <string>
#include <functional>

/**
 *  Set up namespace
 */
namespace AMQP {

/**
 *  Forward declarations
 */
class Message;
class MetaData;

/**
 *  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()>;
using CountCallback         =   std::function<void(uint32_t messagecount)>;
using SizeCallback          =   std::function<void(uint64_t messagesize)>;

/**
 *  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)>;

/**
 * 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)>;

/**
 * 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()>;
using PublishLostCallback          =   std::function<void()>;

/**
 *  End namespace
 */
}