Tüm Ürünler
Search
Belge Merkezi

ApsaraMQ for RocketMQ:Abonelik tutarlılığı

Son Güncelleme:Oct 04, 2026

ApsaraMQ for RocketMQ'da abonelik tutarlılığı, aynı grup kimliğiyle tanımlanan tüm tüketici örneklerinin aynı konulara ve etiketlere abone olması anlamına gelir. Tutarlı olmayan abonelikler, mesaj tüketme mantığında hatalara ve mesajların tekrarlanarak veya eksik olarak tüketilmesine neden olabilir.

Abonelik tutarlılığı nedir?

ApsaraMQ for RocketMQ ortamında bir tüketici grubu, birden fazla tüketici örneğinden oluşur. Çoğu dağıtık uygulamada, tek bir tüketici grubuna bağlı birden çok tüketici örneği bulunur.

ApsaraMQ for RocketMQ bağlamında abonelik; bir tüketici grubu ile belirli bir konu arasındaki ilişkiyi ifade eder. Bu ilişki, abone olunan konudaki mesajları filtrelemek için kullanılan koşulları da kapsar.

Aboneliklerin tutarlı olmasını sağlamak için, aynı grup kimliğiyle tanımlanan tüm tüketici örneklerinin aşağıdaki açılardan birebir eşleşmesi gerekir:

  • Tüketici örneklerinin abone olduğu konular aynı olmalıdır.

    Örneğin, Tüketici 1 A Konusu ve B Konusu'na aboneyse, aynı gruptaki Tüketici 2 de hem A Konusu'na hem de B Konusu'na abone olmalıdır. Tüketici 2 yalnızca A veya B konusuna abone olamaz ya da A ve C konularına abone olamaz.

  • Tüketici örneklerinin konulardaki abone oldukları etiketler; etiket sayısı ve sıralaması dahil olmak üzere tutarlı olmalıdır.

    Örneğin, Tüketici 1 B Konusu'ndaki Tag1||Tag2 etiketlerine aboneyse, aynı gruptaki Tüketici 2 de B Konusu'nda Tag1||Tag2 etiketlerine abone olmalıdır. Tüketici 2 yalnızca Tag1 veya Tag2 etiketine abone olamaz veya B Konusu'nda Tag2||Tag1 şeklinde farklı bir sırayla abone olamaz.

  • Bir tüketici grubundaki örnekler birden fazla konuya aboneyse, bu konuların mesaj türleri aynı olmalıdır.

    Örneğin, Tüketici 1 ve Tüketici 2 hem A Konusu'na hem de B Konusu'na aboneyse, her iki konunun da normal mesaj veya sıralı mesaj gibi aynı mesaj türünde olması gerekir. ApsaraMQ for RocketMQ tarafından desteklenen mesaj türleri hakkında bilgi için bkz. Mesaj türleri.

Aşağıdaki görselde tutarlı abonelik ilişkisine bir örnek gösterilmektedir. Farklı kimliklere sahip gruplar farklı konulara abonedir. Her grup C1, C2 ve C3 adlı tüketici örneklerini içerir. Aynı gruptaki tüm tüketici örnekleri aynı konulara ve etiketlere abonedir.正确订阅关系

Önemli

ApsaraMQ for RocketMQ ile TCP ve HTTP istemci SDK'larını kullanarak mesaj gönderip alabilirsiniz. Aynı gruptaki tüketici örneklerinin abonelik tutarlılığını sağlamanın yanı sıra, mesajlara abone olan tüketici grubunun protokol sürümü ile SDK'nın protokol sürümü arasında da tutarlılık olmalıdır. Örneğin, mesaj göndermek ve almak için TCP istemci SDK'sı kullanıyorsanız, mesajlara abone olmak için de TCP protokolünü kullanan bir tüketici grubu kullanmanız gerekir. Aksi takdirde mesajlar tüketilemez.

Bir gruptaki tüketici örneklerinin aboneliklerinin tutarlı olup olmadığını nasıl kontrol ederim?

Bir gruptaki tüketici örneklerinin aboneliklerinin tutarlı olup olmadığını kontrol etmek için aşağıdaki adımları izleyin:

  1. ApsaraMQ for RocketMQ konsolu üzerinde oturum açın. Instances sayfasında yönetmek istediğiniz örneği bulun ve örneğin adına tıklayarak Instance Details sayfasına gidin.

  2. Sol gezinme bölmesinde Groups seçeneğine tıklayın. Açılan sayfada yönetmek istediğiniz tüketici grubunun adına tıklayın.

  3. Group Details sayfasının Subscriptions bölümünde tüketici grubunun aboneliklerinin tutarlı olup olmadığını kontrol edin.

Tutarlı abonelik 1: Tek konuda tek etiket

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Bu örnekler A Konusu'ndaki Tag 1 etiketine abonedir. Bu senaryo abonelik tutarlılığı gereksinimlerini karşılar.

**正确示例1Sample code of consistent subscription 1**

C1, C2 ve C3'ün abonelikleri tutarlıdır. Bu nedenle, bu üç örnek için yazılan mesaj abonelik kodu aynı olmalıdır. Örnek kod:

    Properties properties = new Properties();
    properties.put(PropertyKeyConst.GROUP_ID, "GID_test_1");
    Consumer consumer = ONSFactory.createConsumer(properties);
    consumer.subscribe("TopicA", "Tag1", new MessageListener() {
        public Action consume(Message message, ConsumeContext context) {
            System.out.println(message.getMsgID());
            return Action.CommitMessage;
        }
    });                    

Tutarlı abonelik 2: Tek konuda birden çok etiket

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Bu örnekler B Konusu'ndaki Tag1||Tag2 etiketlerine abonedir. Böylece tüm tüketici örnekleri B Konusu'ndaki Tag 1 veya Tag 2 etiketli mesajları aynı sırada tüketir. Bu senaryo abonelik tutarlılığı gereksinimlerini karşılar.

**正确示例2Sample code of consistent subscription 2**

C1, C2 ve C3'ün abonelikleri tutarlıdır. Bu nedenle, bu üç örnek için yazılan mesaj abonelik kodu aynı olmalıdır. Örnek kod:

    Properties properties = new Properties();
    properties.put(PropertyKeyConst.GROUP_ID, "GID_test_2");
    Consumer consumer = ONSFactory.createConsumer(properties);
    consumer.subscribe("TopicB", "Tag1||Tag2", new MessageListener() {
        public Action consume(Message message, ConsumeContext context) {
            System.out.println(message.getMsgID());
            return Action.CommitMessage;
        }
    });                    

Tutarlı abonelik 3: Birden çok konuda birden çok etiket

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Bu örnekler hem A Konusu'na hem de B Konusu'na abonedir. A Konusu için herhangi bir etiket belirtilmemiştir, ancak B Konusu için Tag1||Tag2 etiketleri belirtilmiştir. Bu durumda tüketici örnekleri, A Konusu'ndaki tüm mesajları ve B Konusu'ndaki Tag 1 veya Tag 2 etiketli mesajları aynı sırada tüketir. Bu senaryo abonelik tutarlılığı gereksinimlerini karşılar.

**正确示例3Sample code of consistent subscription 3**

C1, C2 ve C3'ün abonelikleri tutarlıdır. Bu nedenle, bu üç örnek için yazılan mesaj abonelik kodu aynı olmalıdır. Örnek kod:

    Properties properties = new Properties();
    properties.put(PropertyKeyConst.GROUP_ID, "GID_test_3");
    Consumer consumer = ONSFactory.createConsumer(properties);
    consumer.subscribe("TopicA", "*", new MessageListener() {
        public Action consume(Message message, ConsumeContext context) {
            System.out.println(message.getMsgID());
            return Action.CommitMessage;
        }
    });     
    consumer.subscribe("TopicB", "Tag1||Tag2", new MessageListener() {
        public Action consume(Message message, ConsumeContext context) {
            System.out.println(message.getMsgID());
            return Action.CommitMessage;
        }
    });                   

Tutarlı olmayan abonelikler

ApsaraMQ for RocketMQ kullanarak mesaj gönderip aldığınızda, tüketici örneklerinin beklenen şekilde mesaj almaması ve ApsaraMQ for RocketMQ konsolunda görüntülenen aboneliklerin tutarsız olması durumunda, bunun nedeni tüketici örneklerinde meydana gelen aşağıdaki sorunlardan biri olabilir:

Tutarsız abonelik 1: Aynı gruba ait tüketici örneklerinin farklı konulara abone olması

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Ancak bu örnekler farklı konulara abonedir. C1 A Konusu'na, C2 B Konusu'na, C3 ise C Konusu'na abonedir. Bu senaryo abonelik tutarlılığı gereksinimlerini karşılamaz.

错误示例1

Tutarsız abonelik 1'in örnek kodu

  • Tüketici örneği 1:

  •     Properties properties = new Properties();
        properties.put(PropertyKeyConst.GROUP_ID, "GID_test_1");
        Consumer consumer = ONSFactory.createConsumer(properties);
        consumer.subscribe("TopicA", "*", new MessageListener() {
            public Action consume(Message message, ConsumeContext context) {
                System.out.println(message.getMsgID());
                return Action.CommitMessage;
            }
        });                    
  • Tüketici örneği 2:

  •     Properties properties = new Properties();
        properties.put(PropertyKeyConst.GROUP_ID, "GID_test_1");
        Consumer consumer = ONSFactory.createConsumer(properties);
        consumer.subscribe("TopicC", "*", new MessageListener() {
            public Action consume(Message message, ConsumeContext context) {
                System.out.println(message.getMsgID());
                return Action.CommitMessage;
            }
        });                    
  • Tüketici örneği 3:

  •     Properties properties = new Properties();
        properties.put(PropertyKeyConst.GROUP_ID, "GID_test_1");
        Consumer consumer = ONSFactory.createConsumer(properties);
        consumer.subscribe("TopicB", "*", new MessageListener() {
            public Action consume(Message message, ConsumeContext context) {
                System.out.println(message.getMsgID());
                return Action.CommitMessage;
            }
        });                    

Tutarsız abonelik 2: Aynı gruba ait tüketici örneklerinin aynı konudaki farklı etiketlere abone olması

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Tüm örnekler A Konusu'na abonedir. Ancak C1 A Konusu'ndaki Tag 1 etiketine aboneyken, C2 ve C3 A Konusu'ndaki Tag 2 etiketine abonedir. Tüketici örnekleri aynı konudaki farklı etiketlere abone olduğundan bu senaryo abonelik tutarlılığı gereksinimlerini karşılamaz.

错误示例2

Tutarsız abonelik 2'nin örnek kodu

  • Tüketici örneği 1:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_2");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "Tag1", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
  • Tüketici örneği 2:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_2");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "Tag2", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
  • Tüketici örneği 3:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_2");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "Tag2", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 

Tutarsız abonelik 3: Aynı gruba ait tüketici örneklerinin aynı konuya ve aynı etiketlere abone olması ancak etiketlerin farklı sıralarda belirtilmesi

Aşağıdaki görselde C1, C2 ve C3 tüketici örnekleri aynı gruba aittir. Bu örnekler hem A Konusu'na hem de B Konusu'na abonedir. A Konusu için etiket belirtilmemiştir. B Konusu için ise Tag 1 ve Tag 2 etiketleri belirtilmiştir. Ancak C1 B Konusu'ndaki Tag1||Tag2 etiketlerine aboneyken, C2 ve C3 B Konusu'ndaki Tag2||Tag1 etiketlerine abonedir. Etiket sıralamasındaki bu fark nedeniyle senaryo abonelik tutarlılığı gereksinimlerini karşılamaz.

错误示例3

Tutarsız abonelik 3'ün örnek kodu

  • Tüketici örneği 1:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_3");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "*", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
     consumer.subscribe("TopicB", "Tag1||Tag2", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
  • Tüketici örneği 2:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_3");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "*", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
     consumer.subscribe("TopicB", "Tag2||Tag1", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
  • Tüketici örneği 3:

     Properties properties = new Properties();
     properties.put(PropertyKeyConst.GROUP_ID, "GID_test_3");
     Consumer consumer = ONSFactory.createConsumer(properties);
     consumer.subscribe("TopicA", "*", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 
     consumer.subscribe("TopicB", "Tag2||Tag1", new MessageListener() {
     public Action consume(Message message, ConsumeContext context) {
     System.out.println(message.getMsgID());
     return Action.CommitMessage;
     }
     }); 

SSS

Bir tüketici grubu birden fazla konuya abone olabilir mi?

Evet, bir tüketici grubu birden fazla konuya abone olabilir. Tüketici grubu belirli bir konuya abone olduğunda bir abonelik oluşturulur. Tüketici grubundaki tüm tüketici örneklerinin söz konusu konuya abone olduğundan emin olun.

ApsaraMQ for RocketMQ konsolunda bir aboneliği silebilir miyim?

Hayır, ApsaraMQ for RocketMQ konsolunda doğrudan bir aboneliği silemezsiniz. Aboneliği silmek için istemci kodunuzdaki ilgili parametreyi yapılandırmanız gerekir.