7#include "models/consumer_client_models.hpp"
8#include "models/management_models.hpp"
9#include "partition_client.hpp"
11#include <azure/core/amqp.hpp>
12#include <azure/core/amqp/internal/connection.hpp>
13#include <azure/core/context.hpp>
14#include <azure/core/credentials/credentials.hpp>
15#include <azure/core/diagnostics/logger.hpp>
16#include <azure/core/http/policies/policy.hpp>
17#include <azure/core/internal/diagnostics/log.hpp>
18namespace Azure {
namespace Messaging {
namespace EventHubs {
20 class EventHubsPropertiesClient;
24 constexpr const char* DefaultConsumerGroup =
"$Default";
119 std::string
const& connectionString,
120 std::string
const& eventHub = {},
121 std::string
const& consumerGroup = DefaultConsumerGroup,
122 ConsumerClientOptions
const& options = {});
135 std::string
const& fullyQualifiedNamespace,
136 std::string
const& eventHub,
137 std::shared_ptr<Azure::Core::Credentials::TokenCredential> credential,
138 std::string
const& consumerGroup = DefaultConsumerGroup,
139 ConsumerClientOptions
const& options = {});
148 std::string
const& partitionId,
149 PartitionClientOptions
const& options = {},
150 Azure::Core::Context
const& context = {});
158 void Close(Azure::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_consumerGroup;
191 std::shared_ptr<Core::Credentials::TokenCredential> m_credential;
194 std::string m_hostUrl;
199 std::uint16_t m_targetPort = Azure::Core::Amqp::_internal::AmqpTlsPort;
202 std::mutex m_receiversLock;
203 std::map<std::string, Azure::Core::Amqp::_internal::MessageReceiver> m_receivers;
206 std::recursive_mutex m_sessionsLock;
207 std::map<std::string, Azure::Core::Amqp::_internal::Session> m_sessions;
208 std::map<std::string, Azure::Core::Amqp::_internal::Connection> m_connections;
211 std::mutex m_propertiesClientLock;
212 std::shared_ptr<_detail::EventHubsPropertiesClient> m_propertiesClient;
215 ConsumerClientOptions m_consumerClientOptions;
217 void EnsureConnection(std::string
const& partitionId);
218 void EnsureSession(std::string
const& partitionId);
219 Azure::Core::Amqp::_internal::Connection CreateConnection(std::string
const& partitionId)
const;
220 Azure::Core::Amqp::_internal::Session CreateSession(std::string
const& partitionId)
const;
221 Azure::Core::Amqp::_internal::Session GetSession(std::string
const& partitionId);
222 std::shared_ptr<_detail::EventHubsPropertiesClient> GetPropertiesClient();
The ConsumerClient class is a high level class used to consume events from an Event Hub.
Definition consumer_client.hpp:52
ConsumerClient & operator=(ConsumerClient const &other)=delete
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 consumer_client.cpp:178
std::string const & GetConsumerGroup() const
Getter for consumer group name.
Definition consumer_client.hpp:78
PartitionClient CreatePartitionClient(std::string const &partitionId, PartitionClientOptions const &options={}, Azure::Core::Context const &context={})
Create new Partition client.
Definition consumer_client.cpp:154
ConsumerClient(ConsumerClient &&other)=delete
void Close(Azure::Core::Context const &context)
Closes the consumer client canceling any operations outstanding on any of the existing partition clie...
Definition consumer_client.cpp:78
ConsumerClient & operator=(ConsumerClient &&other)=delete
ConsumerClient(ConsumerClient const &other)=delete
Models::EventHubProperties GetEventHubProperties(Core::Context const &context={})
GetEventHubProperties gets properties of an eventHub. This includes data like name,...
Definition consumer_client.cpp:173
std::string const & GetEventHubName() const
Getter for event hub name.
Definition consumer_client.hpp:72
Models::ConsumerClientDetails GetDetails() const
Getter for client details.
Definition consumer_client.hpp:84
Azure::Core::Http::Policies::RetryOptions const & GetRetryOptions() const
Getter for retry options.
Definition consumer_client.hpp:97
Contains options for the ConsumerClient creation.
Definition consumer_client.hpp:29
std::string ApplicationID
ApplicationID is used as the identifier when setting the User-Agent property.
Definition consumer_client.hpp:32
Azure::Core::Http::Policies::RetryOptions RetryOptions
RetryOptions controls how often operations are retried from this client and any Receivers and Senders...
Definition consumer_client.hpp:37
std::string Name
Name of the consumer client.
Definition consumer_client.hpp:40
Contains options for the ConsumerClient creation.
Definition consumer_client_models.hpp:13
std::string ClientId
A unique name used to identify this consumer.
Definition consumer_client_models.hpp:29
std::string FullyQualifiedNamespace
The Fully Qualified Namespace that the Event Hub exists in.
Definition consumer_client_models.hpp:16
std::string ConsumerGroup
The name of the consumer group that this consumer is associated with. Events will be read only in the...
Definition consumer_client_models.hpp:21
std::string EventHubName
The name of the Event Hub that the consumer is connected to.
Definition consumer_client_models.hpp:25