In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1 theme
URL of the topic name structure:
{persistent | non-persistent}: / / tenant/namespace/topic
The name consists of a snap-in that describes the persistent / non-persistent persistent and non-persistent tenant tenant namespace namespace topics and serves as a grouping mechanism for related topics. Most topic configurations are performed at the namespace level. Each tenant can have multiple namespaces, the last part of the topic name
No need to explicitly create a new theme
You don't need to explicitly create a theme in Pulsar. If the client attempts to write or receive a message to a topic that does not already exist, Pulsar will automatically create the topic under the namespace provided in the topic name
2 Namespace
A namespace is a logical term in a tenant. Tenants can create multiple namespaces by managing API. For example, tenants with different applications can create separate namespaces for each application. Namespaces allow applications to create and manage hierarchies of topics. The theme my tenant/app1 is the namespace of my tenant's application app1. You can create any number of topics under the namespace
3 subscription mode
Pulsar has three subscription modes: exclusive, shared, and failover.
Exclusive mode is the default subscription mode
Limitations of sharing mode
There are two important things to be aware of when using shared mode:
Message ordering cannot be guaranteed.
You cannot use cumulative confirmation with shared mode.
4 key sharing (Key_shared)
In secret sharing mode, multiple messengers can subscribe to the same
Restrictions on key sharing mode
There are two important things to be aware of when using the secret sharing mode:
You need to specify a key or orderingKey for the message
Cumulative confirmation cannot be used with key sharing mode
Secret sharing subscription is a beta feature. You can disable it on broker.config (Pulsar 2.4.1)
5 Multi-topic subscription
Starting with Pulsar 1.23.0, Pulsar users can subscribe to multiple topics at the same time in two ways
1) based on regular expressions (regex), such as persistent://public/default/finance-*
2) through a clearly defined topic list
When subscribing to multiple topics through regex, all topics must be in the same namespace
Can't guarantee sequence.
When consumers subscribe to multiple topics, all the subscription guarantees that Pulsar typically provides for a single topic are not valid. If your Pulsar use case involves any strict ordering requirements, we strongly recommend that you do not use this feature
Here are some examples of Java's multi-topic subscriptions:
Import java.util.regex.Pattern
Import org.apache.pulsar.client.api.Consumer
Import org.apache.pulsar.client.api.PulsarClient
PulsarClient pulsarClient = / / Instantiate Pulsar client object
/ / Subscribe to all topics in a namespace
Pattern allTopicsInNamespace = Pattern.compile ("persistent://public/default/.*")
Consumer allTopicsConsumer = pulsarClient.newConsumer ()
.topicsPattern (allTopicsInNamespace)
.subscriptionName ("subscription-1")
.subscribe ()
/ / Subscribe to a subsets of topics in a namespace, based on regex
Pattern someTopicsInNamespace = Pattern.compile ("persistent://public/default/foo.*")
Consumer someTopicsConsumer = pulsarClient.newConsumer ()
.topicsPattern (someTopicsInNamespace)
.subscriptionName ("subscription-1")
.subscribe ()
6 Partition theme
There is no difference between partition topic and normal topic about how the subscription mode works. Partitioning simply determines what happens from the producer's production message to the consumer's processing and confirmation of the message.
The partition topic needs to be specified by admin API. You can specify the number of partitions when you create them.
Route pattern
The pattern states that if RoundRobinPartition does not provide a key, the producer will publish messages on all partitions in a circular manner to achieve maximum throughput. Note that round robin is not performed on a single message, but is set to the same boundary of batch latency to ensure that the batch is valid. If a key is specified on the message, the producer of the partition hashes the key and assigns the message to a specific partition. This is the default mode. If SinglePartition does not provide a key, the producer will randomly select a separate partition and publish all messages to that partition. If a key is specified on the message, the producer of the partition hashes the key and assigns the message to a specific partition. CustomPartition uses the custom message router implementation that will be called to determine the partition of a particular message. Users can create custom route patterns by using the Java client and implementing the MessageRouter interface.
Message order
The order of messages is related to message routing patterns and message keys. Typically, users need to sort by key partition guarantee.
If the message has a key attached, when using SinglePartition or RoundRobinPartition mode, the message will be routed to the appropriate partition according to the hash scheme
The order rule states that route patterns and key distribute by key (Per-key-partition) all messages with the same key will be arranged sequentially and placed in the same partition. Using SinglePartition or RoundRobinPartition mode, each message provides key by producer distribution (Per-producer) all messages from the same producer are arranged sequentially using the SinglePartition pattern, and no key is provided for each message
7 non-persistent themes
The format is as follows:
Non-persistent://tenant/namespace/topic
Producers and consumers can connect to non-persistent topics in the same way as persistent topics, with the key difference that the theme name must start with a non-persistent topic. All three subscription models (exclusive, shared, and failover) support non-persistent topics.
Client API
PulsarClient client = PulsarClient.builder ()
.serviceUrl ("pulsar://localhost:6650")
.build ()
String npTopic = "non-persistent://public/default/my-topic"
String subscriptionName = "my-subscription-name"
Consumption
Consumer consumer = client.newConsumer ()
.topic (npTopic)
.subscriptionName (subscriptionName)
.subscribe ()
Production
Producer producer = client.newProducer ()
.topic (npTopic)
.create ()
8 message retention and expiration
By default, the Pulsar message server:
Immediately delete all messages that have been confirmed by the consumer, and
Persist all unacknowledged messages in the message to-do list.
However, Pulsar has two features that enable you to override this default behavior:
Message retention enables you to store messages that have been acknowledged by consumers
Message expiration enables you to set time to live (TTL) for messages that have not yet been acknowledged
9 message de-duplicated
Data duplication occurs when a message is persisted more than once by Pulsar. Message deduplication is an optional feature of Pulsar, which prevents unnecessary messages from being repeated and each message is processed only once.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.