7#include "event_data_batch.hpp"
8#include "models/management_models.hpp"
10#include <azure/core/amqp.hpp>
11#include <azure/core/amqp/internal/message_sender.hpp>
12#include <azure/core/context.hpp>
13#include <azure/core/credentials/credentials.hpp>
14#include <azure/core/http/policies/policy.hpp>
18namespace Azure {
namespace Messaging {
namespace EventHubs {
20 class EventHubsPropertiesClient;
78 std::string
const& connectionString,
79 std::string
const& eventHub,
90 std::string
const& fullyQualifiedNamespace,
91 std::string
const& eventHub,
92 std::shared_ptr<Azure::Core::Credentials::TokenCredential> credential,
95 ~ProducerClient() {
Close(); }
101 void Close(Azure::Core::Context
const& context = {})
103 for (
auto& sender : m_senders)
105 sender.second.Close(context);
129 EventDataBatchOptions
const& options = {},
130 Azure::Core::Context
const& context = {});
137 void Send(EventDataBatch
const& eventDataBatch, Core::Context
const& context = {});
147 void Send(Models::EventData
const& eventData, Core::Context
const& context = {});
157 void Send(std::vector<Models::EventData>
const& eventData, Core::Context
const& context = {});
174 std::string
const& partitionID,
175 Core::Context
const& context = {});
179 std::string m_connectionString;
182 std::string m_fullyQualifiedNamespace;
185 std::string m_eventHub{};
188 std::string m_targetUrl{};
190 uint16_t m_targetPort = Azure::Core::Amqp::_internal::AmqpTlsPort;
193 std::shared_ptr<Core::Credentials::TokenCredential> m_credential{};
195 ProducerClientOptions m_producerClientOptions{};
198 std::mutex m_sendersLock;
199 std::map<std::string, Azure::Core::Amqp::_internal::Connection> m_connections{};
200 std::map<std::string, Azure::Core::Amqp::_internal::MessageSender> m_senders{};
202 std::recursive_mutex m_sessionsLock;
203 std::map<std::string, Azure::Core::Amqp::_internal::Session> m_sessions{};
205 std::mutex m_propertiesClientLock;
206 std::shared_ptr<_detail::EventHubsPropertiesClient> m_propertiesClient;
208 Azure::Core::Amqp::_internal::Connection CreateConnection()
const;
209 Azure::Core::Amqp::_internal::Session CreateSession(std::string
const& partitionId);
212 void EnsureConnection(
const std::string& partitionId);
215 void EnsureSession(std::string
const& partitionId);
218 void EnsureSender(std::string
const& partitionId, Azure::Core::Context
const& context = {});
220 std::shared_ptr<_detail::EventHubsPropertiesClient> GetPropertiesClient();
222 Azure::Core::Amqp::_internal::MessageSender GetSender(std::string
const& partitionId);
223 Azure::Core::Amqp::_internal::Session GetSession(std::string
const& partitionId);
ProducerClient can be used to send events to an Event Hub.
Definition producer_client.hpp:47
Models::EventHubPartitionProperties GetPartitionProperties(std::string const &partitionID, Core::Context const &context={})
GetPartitionProperties gets properties for a specific partition. This includes data like the last enq...
Definition producer_client.cpp:226
Azure::Core::Http::Policies::RetryOptions const & GetRetryOptions() const
Definition producer_client.hpp:54
ProducerClient & operator=(ProducerClient const &other)=delete
ProducerClient(ProducerClient const &other)=delete
std::string const & GetEventHubName()
Definition producer_client.hpp:51
EventDataBatch CreateBatch(EventDataBatchOptions const &options={}, Azure::Core::Context const &context={})
Create a new EventDataBatch to be sent to the Event Hub.
Definition producer_client.cpp:58
void Send(EventDataBatch const &eventDataBatch, Core::Context const &context={})
Send an EventDataBatch to the remote Event Hub.
Definition producer_client.cpp:74
void Close(Azure::Core::Context const &context={})
Close all the connections and sessions.
Definition producer_client.hpp:101
Models::EventHubProperties GetEventHubProperties(Core::Context const &context={})
GetEventHubProperties gets properties of an eventHub. This includes data like name,...
Definition producer_client.cpp:221
Contains options for the ProducerClient creation.
Definition producer_client.hpp:26
Azure::Core::Http::Policies::RetryOptions RetryOptions
RetryOptions controls how often operations are retried from this client and any Receivers and Senders...
Definition producer_client.hpp:34
Azure::Nullable< std::uint64_t > MaxMessageSize
The maximum size of the message that can be sent.
Definition producer_client.hpp:42
std::string Name
The name of the producer client link, used in diagnostics.
Definition producer_client.hpp:38
std::string ApplicationID
Application ID that will be passed to the namespace.
Definition producer_client.hpp:29