pulsar-client-cpp
Loading...
Searching...
No Matches
consumer_configuration.h
1
19#pragma once
20
21#include <pulsar/defines.h>
22
23#include "consumer.h"
24#include "producer_configuration.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30typedef struct _pulsar_consumer_configuration pulsar_consumer_configuration_t;
31
32typedef enum
33{
37 pulsar_ConsumerExclusive,
38
43 pulsar_ConsumerShared,
44
48 pulsar_ConsumerFailover,
49
54 pulsar_ConsumerKeyShared
55} pulsar_consumer_type;
56
57typedef enum
58{
62 initial_position_latest,
66 initial_position_earliest
67} initial_position;
68
69typedef enum
70{
71 // This is the default option to fail consume until crypto succeeds
72 pulsar_ConsumerFail,
73 // Message is silently acknowledged and not delivered to the application
74 pulsar_ConsumerDiscard,
75 // Deliver the encrypted message to the application. It's the application's
76 // responsibility to decrypt the message. If message is also compressed,
77 // decompression will fail. If message contain batch messages, client will
78 // not be able to retrieve individual messages in the batch
79 pulsar_ConsumerConsume
80} pulsar_consumer_crypto_failure_action;
81
82typedef enum
83{
84 // Only subscribe to persistent topics.
85 pulsar_consumer_regex_sub_mode_PersistentOnly = 0,
86 // Only subscribe to non-persistent topics.
87 pulsar_consumer_regex_sub_mode_NonPersistentOnly = 1,
88 // Subscribe to both persistent and non-persistent topics.
89 pulsar_consumer_regex_sub_mode_AllTopics = 2
90} pulsar_consumer_regex_subscription_mode;
91
92// Though any field could be non-positive, if all of them are non-positive, this policy will be treated as
93// invalid
94typedef struct {
95 // Max num messages, a non-positive value means no limit.
96 int maxNumMessages;
97 // Max num bytes, a non-positive value means no limit.
98 long maxNumBytes;
99 // The receive timeout, a non-positive value means no limit.
100 long timeoutMs;
102
103typedef struct {
104 // Name of the dead topic where the failing messages are sent.
105 // If it's null, use sourceTopicName + "-" + subscriptionName + "-DLQ" as the value
106 const char *dead_letter_topic;
107 // Maximum number of times that a message is redelivered before being sent to the dead letter queue.
108 // If it's not greater than 0, treat it as INT_MAX, it means DLQ disable.
109 int max_redeliver_count;
110 // Name of the initial subscription name of the dead letter topic.
111 // If it's null, the initial subscription for the dead letter topic is not created.
112 // If this field is set but the broker's `allowAutoSubscriptionCreation` is disabled, the DLQ producer
113 // fails to be created.
114 const char *initial_subscription_name;
116
118typedef void (*pulsar_message_listener)(pulsar_consumer_t *consumer, pulsar_message_t *msg, void *ctx);
119
120PULSAR_PUBLIC pulsar_consumer_configuration_t *pulsar_consumer_configuration_create();
121
122PULSAR_PUBLIC void pulsar_consumer_configuration_free(
123 pulsar_consumer_configuration_t *consumer_configuration);
124
137PULSAR_PUBLIC void pulsar_consumer_configuration_set_consumer_type(
138 pulsar_consumer_configuration_t *consumer_configuration, pulsar_consumer_type consumerType);
139
140PULSAR_PUBLIC pulsar_consumer_type
141pulsar_consumer_configuration_get_consumer_type(pulsar_consumer_configuration_t *consumer_configuration);
142
143PULSAR_PUBLIC void pulsar_consumer_configuration_set_schema_info(
144 pulsar_consumer_configuration_t *consumer_configuration, pulsar_schema_type schemaType, const char *name,
145 const char *schema, pulsar_string_map_t *properties);
146
152PULSAR_PUBLIC void pulsar_consumer_configuration_set_message_listener(
153 pulsar_consumer_configuration_t *consumer_configuration, pulsar_message_listener messageListener,
154 void *ctx);
155
156PULSAR_PUBLIC int pulsar_consumer_configuration_has_message_listener(
157 pulsar_consumer_configuration_t *consumer_configuration);
158
180PULSAR_PUBLIC void pulsar_consumer_configuration_set_receiver_queue_size(
181 pulsar_consumer_configuration_t *consumer_configuration, int size);
182
183PULSAR_PUBLIC int pulsar_consumer_configuration_get_receiver_queue_size(
184 pulsar_consumer_configuration_t *consumer_configuration);
185
194PULSAR_PUBLIC void pulsar_consumer_set_max_total_receiver_queue_size_across_partitions(
195 pulsar_consumer_configuration_t *consumer_configuration, int maxTotalReceiverQueueSizeAcrossPartitions);
196
200PULSAR_PUBLIC int pulsar_consumer_get_max_total_receiver_queue_size_across_partitions(
201 pulsar_consumer_configuration_t *consumer_configuration);
202
203PULSAR_PUBLIC void pulsar_consumer_set_consumer_name(pulsar_consumer_configuration_t *consumer_configuration,
204 const char *consumerName);
205
206PULSAR_PUBLIC const char *pulsar_consumer_get_consumer_name(
207 pulsar_consumer_configuration_t *consumer_configuration);
208
216PULSAR_PUBLIC void pulsar_consumer_set_unacked_messages_timeout_ms(
217 pulsar_consumer_configuration_t *consumer_configuration, const uint64_t milliSeconds);
218
222PULSAR_PUBLIC long pulsar_consumer_get_unacked_messages_timeout_ms(
223 pulsar_consumer_configuration_t *consumer_configuration);
224
237PULSAR_PUBLIC void pulsar_configure_set_negative_ack_redelivery_delay_ms(
238 pulsar_consumer_configuration_t *consumer_configuration, long redeliveryDelayMillis);
239
246PULSAR_PUBLIC long pulsar_configure_get_negative_ack_redelivery_delay_ms(
247 pulsar_consumer_configuration_t *consumer_configuration);
248
258PULSAR_PUBLIC void pulsar_configure_set_ack_grouping_time_ms(
259 pulsar_consumer_configuration_t *consumer_configuration, long ackGroupingMillis);
260
267PULSAR_PUBLIC long pulsar_configure_get_ack_grouping_time_ms(
268 pulsar_consumer_configuration_t *consumer_configuration);
269
277PULSAR_PUBLIC void pulsar_configure_set_ack_grouping_max_size(
278 pulsar_consumer_configuration_t *consumer_configuration, long maxGroupingSize);
279
286PULSAR_PUBLIC long pulsar_configure_get_ack_grouping_max_size(
287 pulsar_consumer_configuration_t *consumer_configuration);
288
289PULSAR_PUBLIC int pulsar_consumer_is_encryption_enabled(
290 pulsar_consumer_configuration_t *consumer_configuration);
291
292PULSAR_PUBLIC void pulsar_consumer_configuration_set_default_crypto_key_reader(
293 pulsar_consumer_configuration_t *consumer_configuration, const char *public_key_path,
294 const char *private_key_path);
295
296PULSAR_PUBLIC pulsar_consumer_crypto_failure_action pulsar_consumer_configuration_get_crypto_failure_action(
297 pulsar_consumer_configuration_t *consumer_configuration);
298
299PULSAR_PUBLIC void pulsar_consumer_configuration_set_crypto_failure_action(
300 pulsar_consumer_configuration_t *consumer_configuration,
301 pulsar_consumer_crypto_failure_action cryptoFailureAction);
302
303PULSAR_PUBLIC int pulsar_consumer_is_read_compacted(pulsar_consumer_configuration_t *consumer_configuration);
304
305PULSAR_PUBLIC void pulsar_consumer_set_read_compacted(pulsar_consumer_configuration_t *consumer_configuration,
306 int compacted);
307
308PULSAR_PUBLIC int pulsar_consumer_get_subscription_initial_position(
309 pulsar_consumer_configuration_t *consumer_configuration);
310
311PULSAR_PUBLIC void pulsar_consumer_set_subscription_initial_position(
312 pulsar_consumer_configuration_t *consumer_configuration, initial_position subscriptionInitialPosition);
313
314PULSAR_PUBLIC void pulsar_consumer_configuration_set_property(pulsar_consumer_configuration_t *conf,
315 const char *name, const char *value);
316
317PULSAR_PUBLIC void pulsar_consumer_configuration_set_priority_level(
318 pulsar_consumer_configuration_t *consumer_configuration, int priority_level);
319
320PULSAR_PUBLIC int pulsar_consumer_configuration_get_priority_level(
321 pulsar_consumer_configuration_t *consumer_configuration);
322
323PULSAR_PUBLIC void pulsar_consumer_configuration_set_max_pending_chunked_message(
324 pulsar_consumer_configuration_t *consumer_configuration, int max_pending_chunked_message);
325
326PULSAR_PUBLIC int pulsar_consumer_configuration_get_max_pending_chunked_message(
327 pulsar_consumer_configuration_t *consumer_configuration);
328
329PULSAR_PUBLIC void pulsar_consumer_configuration_set_auto_ack_oldest_chunked_message_on_queue_full(
330 pulsar_consumer_configuration_t *consumer_configuration,
331 int auto_ack_oldest_chunked_message_on_queue_full);
332
333PULSAR_PUBLIC int pulsar_consumer_configuration_is_auto_ack_oldest_chunked_message_on_queue_full(
334 pulsar_consumer_configuration_t *consumer_configuration);
335
336PULSAR_PUBLIC void pulsar_consumer_configuration_set_start_message_id_inclusive(
337 pulsar_consumer_configuration_t *consumer_configuration, int start_message_id_inclusive);
338
339PULSAR_PUBLIC int pulsar_consumer_configuration_is_start_message_id_inclusive(
340 pulsar_consumer_configuration_t *consumer_configuration);
341
342PULSAR_PUBLIC void pulsar_consumer_configuration_set_batch_index_ack_enabled(
343 pulsar_consumer_configuration_t *consumer_configuration, int enabled);
344
345PULSAR_PUBLIC int pulsar_consumer_configuration_is_batch_index_ack_enabled(
346 pulsar_consumer_configuration_t *consumer_configuration);
347
348PULSAR_PUBLIC void pulsar_consumer_configuration_set_regex_subscription_mode(
349 pulsar_consumer_configuration_t *consumer_configuration,
350 pulsar_consumer_regex_subscription_mode regex_sub_mode);
351
352PULSAR_PUBLIC pulsar_consumer_regex_subscription_mode
353pulsar_consumer_configuration_get_regex_subscription_mode(
354 pulsar_consumer_configuration_t *consumer_configuration);
355
367PULSAR_PUBLIC int pulsar_consumer_configuration_set_batch_receive_policy(
368 pulsar_consumer_configuration_t *consumer_configuration,
369 const pulsar_consumer_batch_receive_policy_t *batch_receive_policy);
370
383PULSAR_PUBLIC void pulsar_consumer_configuration_get_batch_receive_policy(
384 pulsar_consumer_configuration_t *consumer_configuration,
385 pulsar_consumer_batch_receive_policy_t *batch_receive_policy);
386
387PULSAR_PUBLIC void pulsar_consumer_configuration_set_dlq_policy(
388 pulsar_consumer_configuration_t *consumer_configuration,
390
399PULSAR_PUBLIC void pulsar_consumer_configuration_get_dlq_policy(
400 pulsar_consumer_configuration_t *consumer_configuration,
402
403// const CryptoKeyReaderPtr getCryptoKeyReader()
404//
405// const;
406// ConsumerConfiguration&
407// setCryptoKeyReader(CryptoKeyReaderPtr
408// cryptoKeyReader);
409//
410// ConsumerCryptoFailureAction getCryptoFailureAction()
411//
412// const;
413// ConsumerConfiguration&
414// setCryptoFailureAction(ConsumerCryptoFailureAction
415// action);
416
417#ifdef __cplusplus
418}
419#endif
Definition consumer_configuration.h:94
Definition consumer_configuration.h:103