Pulsar订阅模式类型SubscriptionType

Posted 抓手

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Pulsar订阅模式类型SubscriptionType相关的知识,希望对你有一定的参考价值。

 Pulsar订阅模式类型SubscriptionType枚举源码

public enum SubscriptionType 
    /**
     * There can be only 1 consumer on the same topic with the same subscription name.
     */
    Exclusive,

    /**
     * Multiple consumer will be able to use the same subscription name and the messages will be dispatched
     * according to a round-robin rotation between the connected consumers.
     *
     * <p>In this mode, the consumption order is not guaranteed.
     */
    Shared,

    /**
     * Multiple consumer will be able to use the same subscription name but only 1 consumer will receive the messages.
     * If that consumer disconnects, one of the other connected consumers will start receiving messages.
     *
     * <p>In failover mode, the consumption ordering is guaranteed.
     *
     * <p>In case of partitioned topics, the ordering is guaranteed on a per-partition basis.
     * The partitions assignments will be split across the available consumers. On each partition,
     * at most one consumer will be active at a given point in time.
     */
    Failover,

    /**
     * Multiple consumer will be able to use the same subscription and all messages with the same key
     * will be dispatched to only one consumer.
     *
     * <p>Use ordering_key to overwrite the message key for message ordering.
     */
    Key_Shared

独占模式(Exclusive)

只允许有一个Consumer加入Subscription ,有其他Consumer试图订阅都会报错,如果该Consumer出现故障了就会停止消费。
Pulsar默认是独占模式(Exclusive)。

共享模式(Shared)

允许多个Consumer加入同一个Subscription,如果Consumer连接异常,就由其他Consumer来接受消息。

灾备模式(Failover)

当存在多个Consumer时,按字典顺序排序,第一个Consumer被初始化为唯一接受消息的消费者。当第一个Consumer断开时,所有被发送给他,但没有被确认的消息将会被分发给队列中的下一个Consumer。

KEY共享模式(Key_Shared)

当存在多个Consumer时,根据消息的key进行分发,key相同的消息只会被分发到同一个消费者。

以上是关于Pulsar订阅模式类型SubscriptionType的主要内容,如果未能解决你的问题,请参考以下文章

Pulsar 介绍

Pulsar消息发送消费架构概述

Pulsar

由于错误的模式类型(JSON 而不是 AVRO),Pulsar 函数无法反序列化消息

[Pulsar系列] 10分钟学会Pulsar消息系统概念

Pulsar介绍