Java Code Examples for org.apache.pulsar.client.api.ConsumerBuilder#consumerName()
The following examples show how to use
org.apache.pulsar.client.api.ConsumerBuilder#consumerName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PulsarConsumerKafkaConfig.java From pulsar with Apache License 2.0 | 5 votes |
public static ConsumerBuilder<byte[]> getConsumerBuilder(PulsarClient client, Properties properties) { ConsumerBuilder<byte[]> consumerBuilder = client.newConsumer(); if (properties.containsKey(CONSUMER_NAME)) { consumerBuilder.consumerName(properties.getProperty(CONSUMER_NAME)); } if (properties.containsKey(RECEIVER_QUEUE_SIZE)) { consumerBuilder.receiverQueueSize(Integer.parseInt(properties.getProperty(RECEIVER_QUEUE_SIZE))); } if (properties.containsKey(TOTAL_RECEIVER_QUEUE_SIZE_ACROSS_PARTITIONS)) { consumerBuilder.maxTotalReceiverQueueSizeAcrossPartitions( Integer.parseInt(properties.getProperty(TOTAL_RECEIVER_QUEUE_SIZE_ACROSS_PARTITIONS))); } if (properties.containsKey(ACKNOWLEDGEMENTS_GROUP_TIME_MILLIS)) { consumerBuilder.acknowledgmentGroupTime( Long.parseLong(properties.getProperty(ACKNOWLEDGEMENTS_GROUP_TIME_MILLIS)), TimeUnit.MILLISECONDS); } if (properties.containsKey(SUBSCRIPTION_TOPICS_MODE)) { RegexSubscriptionMode mode; try { mode = RegexSubscriptionMode.valueOf(properties.getProperty(SUBSCRIPTION_TOPICS_MODE)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Illegal subscription mode, valid values are: " + Arrays.asList(RegexSubscriptionMode.values())); } consumerBuilder.subscriptionTopicsMode(mode); } return consumerBuilder; }
Example 2
Source File: PulsarConsumerKafkaConfig.java From pulsar with Apache License 2.0 | 5 votes |
public static ConsumerBuilder<byte[]> getConsumerBuilder(PulsarClient client, Properties properties) { ConsumerBuilder<byte[]> consumerBuilder = client.newConsumer(); if (properties.containsKey(CONSUMER_NAME)) { consumerBuilder.consumerName(properties.getProperty(CONSUMER_NAME)); } if (properties.containsKey(RECEIVER_QUEUE_SIZE)) { consumerBuilder.receiverQueueSize(Integer.parseInt(properties.getProperty(RECEIVER_QUEUE_SIZE))); } if (properties.containsKey(TOTAL_RECEIVER_QUEUE_SIZE_ACROSS_PARTITIONS)) { consumerBuilder.maxTotalReceiverQueueSizeAcrossPartitions( Integer.parseInt(properties.getProperty(TOTAL_RECEIVER_QUEUE_SIZE_ACROSS_PARTITIONS))); } if (properties.containsKey(ACKNOWLEDGEMENTS_GROUP_TIME_MILLIS)) { consumerBuilder.acknowledgmentGroupTime( Long.parseLong(properties.getProperty(ACKNOWLEDGEMENTS_GROUP_TIME_MILLIS)), TimeUnit.MILLISECONDS); } if (properties.containsKey(SUBSCRIPTION_TOPICS_MODE)) { RegexSubscriptionMode mode; try { mode = RegexSubscriptionMode.valueOf(properties.getProperty(SUBSCRIPTION_TOPICS_MODE)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Illegal subscription mode, valid values are: " + Arrays.asList(RegexSubscriptionMode.values())); } consumerBuilder.subscriptionTopicsMode(mode); } return consumerBuilder; }
Example 3
Source File: ConsumerHandler.java From pulsar with Apache License 2.0 | 5 votes |
private ConsumerBuilder<byte[]> getConsumerConfiguration(PulsarClient client) { ConsumerBuilder<byte[]> builder = client.newConsumer(); if (queryParams.containsKey("ackTimeoutMillis")) { builder.ackTimeout(Integer.parseInt(queryParams.get("ackTimeoutMillis")), TimeUnit.MILLISECONDS); } if (queryParams.containsKey("subscriptionType")) { checkArgument(Enums.getIfPresent(SubscriptionType.class, queryParams.get("subscriptionType")).isPresent(), "Invalid subscriptionType %s", queryParams.get("subscriptionType")); builder.subscriptionType(SubscriptionType.valueOf(queryParams.get("subscriptionType"))); } if (queryParams.containsKey("receiverQueueSize")) { builder.receiverQueueSize(Math.min(Integer.parseInt(queryParams.get("receiverQueueSize")), 1000)); } if (queryParams.containsKey("consumerName")) { builder.consumerName(queryParams.get("consumerName")); } if (queryParams.containsKey("priorityLevel")) { builder.priorityLevel(Integer.parseInt(queryParams.get("priorityLevel"))); } if (queryParams.containsKey("maxRedeliverCount") || queryParams.containsKey("deadLetterTopic")) { DeadLetterPolicy.DeadLetterPolicyBuilder dlpBuilder = DeadLetterPolicy.builder(); if (queryParams.containsKey("maxRedeliverCount")) { dlpBuilder.maxRedeliverCount(Integer.parseInt(queryParams.get("maxRedeliverCount"))) .deadLetterTopic(String.format("%s-%s-DLQ", topic, subscription)); } if (queryParams.containsKey("deadLetterTopic")) { dlpBuilder.deadLetterTopic(queryParams.get("deadLetterTopic")); } builder.deadLetterPolicy(dlpBuilder.build()); } return builder; }