azure-messaging-eventhubs
Loading...
Searching...
No Matches
event_data.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3#pragma once
4
5#include <azure/core/amqp/models/amqp_message.hpp>
6#include <azure/core/amqp/models/amqp_value.hpp>
7#include <azure/core/datetime.hpp>
8#include <azure/core/nullable.hpp>
9
10#include <initializer_list>
11#include <iostream>
12#include <map>
13#include <vector>
14
15namespace Azure { namespace Messaging { namespace EventHubs { namespace Models {
16
19 class EventData {
20 public:
23 std::vector<uint8_t> Body;
24
26 Azure::Nullable<std::string> ContentType;
27
33 Azure::Nullable<Azure::Core::Amqp::Models::AmqpValue> CorrelationId;
34
41 Azure::Nullable<Azure::Core::Amqp::Models::AmqpValue> MessageId;
42
47 std::map<std::string, Azure::Core::Amqp::Models::AmqpValue> Properties;
48
50 EventData() : m_message{nullptr} {};
51
56 EventData(std::shared_ptr<Azure::Core::Amqp::Models::AmqpMessage const> const& message);
57
62 EventData(std::initializer_list<uint8_t> const& body) : Body(body), m_message{nullptr} {}
63
68 EventData(std::vector<uint8_t> const& body) : Body(body), m_message{nullptr} {}
69
74 EventData(std::string const& body) : Body(body.begin(), body.end()), m_message{nullptr} {}
75
76 virtual ~EventData() = default;
77
80 EventData(EventData const&) = default;
81
84 EventData& operator=(EventData const&) = default;
85
88 EventData(EventData&&) = default;
89
93
103 virtual std::shared_ptr<Azure::Core::Amqp::Models::AmqpMessage const> GetRawAmqpMessage() const;
104
105 protected:
107 std::shared_ptr<Azure::Core::Amqp::Models::AmqpMessage const> m_message;
108 };
109 std::ostream& operator<<(std::ostream&, EventData const&);
110
117 class ReceivedEventData final : public EventData {
118 public:
123 Azure::Nullable<Azure::DateTime> EnqueuedTime;
124
130 Azure::Nullable<std::uint64_t> Offset;
131
138 Azure::Nullable<std::string> PartitionKey;
139
144 Azure::Nullable<std::int64_t> SequenceNumber;
145
150 std::map<std::string, Azure::Core::Amqp::Models::AmqpValue> SystemProperties;
151
156 ReceivedEventData(std::shared_ptr<Azure::Core::Amqp::Models::AmqpMessage const> const& message);
157
158 // Destructor
159 ~ReceivedEventData() = default;
160
164
169
173
177
182 std::shared_ptr<Azure::Core::Amqp::Models::AmqpMessage const> GetRawAmqpMessage() const override
183 {
184 return m_message;
185 }
186 };
187 std::ostream& operator<<(std::ostream&, ReceivedEventData const&);
188}}}} // namespace Azure::Messaging::EventHubs::Models
Represents an event sent to the Azure Event Hubs service.
Definition event_data.hpp:19
std::vector< uint8_t > Body
The body of the event data.
Definition event_data.hpp:23
Azure::Nullable< Azure::Core::Amqp::Models::AmqpValue > MessageId
The message identifier.
Definition event_data.hpp:41
EventData & operator=(EventData &&)=default
Azure::Nullable< std::string > ContentType
Definition event_data.hpp:26
Azure::Nullable< Azure::Core::Amqp::Models::AmqpValue > CorrelationId
The correlation identifier.
Definition event_data.hpp:33
EventData & operator=(EventData const &)=default
EventData()
Construct a default EventData object.
Definition event_data.hpp:50
std::shared_ptr< Azure::Core::Amqp::Models::AmqpMessage const > m_message
Definition event_data.hpp:107
EventData(std::vector< uint8_t > const &body)
Construct a new EventData object from a vector of bytes.
Definition event_data.hpp:68
std::map< std::string, Azure::Core::Amqp::Models::AmqpValue > Properties
The set of free-form event properties.
Definition event_data.hpp:47
EventData(std::string const &body)
Construct a new EventData object from a string.
Definition event_data.hpp:74
virtual std::shared_ptr< Azure::Core::Amqp::Models::AmqpMessage const > GetRawAmqpMessage() const
Get the AMQP message associated with this EventData.
Definition event_data.cpp:108
EventData(std::initializer_list< uint8_t > const &body)
Construct a new EventData object from an initializer list of bytes.
Definition event_data.hpp:62
Represents an event received from the Azure Event Hubs service.
Definition event_data.hpp:117
Azure::Nullable< Azure::DateTime > EnqueuedTime
The date and time that the event was enqueued.
Definition event_data.hpp:123
std::map< std::string, Azure::Core::Amqp::Models::AmqpValue > SystemProperties
The set of system properties populated by the Event Hubs service.
Definition event_data.hpp:150
ReceivedEventData & operator=(ReceivedEventData const &)=default
Assign an ReceivedEventData to another. /.
ReceivedEventData & operator=(ReceivedEventData &&)=default
Move an ReceivedEventData to another.
Azure::Nullable< std::int64_t > SequenceNumber
The sequence number of the event data.
Definition event_data.hpp:144
ReceivedEventData(ReceivedEventData &&)=default
Create an ReceivedEventData moving from another.
Azure::Nullable< std::string > PartitionKey
The partition key for sending a message to a partition.
Definition event_data.hpp:138
Azure::Nullable< std::uint64_t > Offset
The offset of the event data within the partition.
Definition event_data.hpp:130
ReceivedEventData(ReceivedEventData const &)=default
Copy an ReceivedEventData to another.
std::shared_ptr< Azure::Core::Amqp::Models::AmqpMessage const > GetRawAmqpMessage() const override
Get the raw AMQP message.
Definition event_data.hpp:182