azure-messaging-eventhubs
Loading...
Searching...
No Matches
processor_partition_client.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3#pragma once
4#include "checkpoint_store.hpp"
5#include "consumer_client.hpp"
6
7namespace Azure { namespace Messaging { namespace EventHubs {
8
18 friend class Processor;
19
20 public:
23
26
29
32
34
39 std::vector<std::shared_ptr<const Models::ReceivedEventData>> ReceiveEvents(
40 uint32_t maxBatchSize,
41 Core::Context const& context = {})
42 {
43 return m_partitionClient->ReceiveEvents(maxBatchSize, context);
44 }
45
55 std::shared_ptr<const Models::ReceivedEventData> const& eventData,
56 Core::Context const& context = {});
57
59 std::string PartitionId() const { return m_partitionId; }
60
65 void Close(Core::Context const& context = {})
66 {
67 if (m_cleanupFunc)
68 {
69 m_cleanupFunc();
70 }
71 m_partitionClient->Close(context);
72 }
73
74 private:
75 std::string m_partitionId;
76 std::unique_ptr<PartitionClient> m_partitionClient{};
77 std::shared_ptr<CheckpointStore> m_checkpointStore;
78 std::function<void()> m_cleanupFunc;
79 Models::ConsumerClientDetails m_consumerClientDetails;
80
87 ProcessorPartitionClient(
88 std::string partitionId,
89 std::shared_ptr<CheckpointStore> checkpointStore,
90 Models::ConsumerClientDetails consumerClientDetails,
91 std::function<void()> cleanupFunc)
92 : m_partitionId(partitionId), m_checkpointStore(checkpointStore),
93 m_cleanupFunc(cleanupFunc), m_consumerClientDetails(consumerClientDetails)
94 {
95 }
96
97 void SetPartitionClient(std::unique_ptr<PartitionClient>& partitionClient)
98 {
99 m_partitionClient = std::move(partitionClient);
100 }
101
102 void UpdateCheckpoint(
103 Azure::Core::Amqp::Models::AmqpMessage const& amqpMessage,
104 Core::Context const& context = {});
105 std::string GetPartitionId() { return m_partitionId; }
106 };
107}}} // namespace Azure::Messaging::EventHubs
Processor uses a ConsumerClient and CheckpointStore to provide automatic load balancing between multi...
Definition processor.hpp:84
ProcessorPartitionClient allows you to receive events, similar to a [PartitionClient],...
Definition processor_partition_client.hpp:17
void Close(Core::Context const &context={})
Closes the partition client.
Definition processor_partition_client.hpp:65
void UpdateCheckpoint(std::shared_ptr< const Models::ReceivedEventData > const &eventData, Core::Context const &context={})
Updates the checkpoint for this partition using the given event data.
Definition processor_partition_client.cpp:67
std::string PartitionId() const
Returns the partition ID associated with this ProcessorPartitionClient.
Definition processor_partition_client.hpp:59
ProcessorPartitionClient & operator=(ProcessorPartitionClient &&other)=default
Move a ProcessorPartitionClient to another.
ProcessorPartitionClient(ProcessorPartitionClient &&other)=default
Move a ProcessorPartitionClient to another.
ProcessorPartitionClient(ProcessorPartitionClient const &other)=delete
Copy a ProcessorPartitionClient to another ProcessorPartitionClient.
std::vector< std::shared_ptr< const Models::ReceivedEventData > > ReceiveEvents(uint32_t maxBatchSize, Core::Context const &context={})
Definition processor_partition_client.hpp:39
ProcessorPartitionClient & operator=(ProcessorPartitionClient const &other)=delete
Assignment operator.