edit-icon download-icon

What should I do if I received an alarm about inconsistent subscriptions?

Last Updated: Sep 18, 2018

Description

  • Consumer ID does not receive all the messages. Log on MQ console. Click Message Query > By Message ID. Although it shows that messages have been consumed for at least once, no consumption occurs by logic.

  • Log on MQ console. Click Consumers > Consumer Status. The bar of Subscription Consistency shows No.

Analysis

In MQ, a Consumer ID represents a set of Consumer Instances. For most distributed applications, a Consumer ID generally has multiple Consumer Instances. Subscriptioin Consistency means that the Topics and Tags of all the Consummer Instances of a Consumer ID are same.

If a Consumer ID has Consumer Instances with different Topics or Tags, subscription inconsistency will occur. Illogical message consumption and message loss hapen as a result.

Possible reason 1

Topics are different.

Example

Consumer ID, CID-MQ-FAQ, subscribes to two Topics, MQ-FAQ-TOPIC-1 and MQ-FAQ-TOPIC-2.

Code of JVM-1

  1. Properties properties = new Properties();
  2. properties.put(PropertyKeyConst.ConsumerId, "CID-MQ-FAQ");
  3. Consumer consumer = ONSFactory.createConsumer(properties);
  4. consumer.subscribe("MQ-FAQ-TOPIC-1", "NM-MQ-FAQ", new MessageListener() {
  5. public Action consume(Message message, ConsumeContext context) {
  6. System.out.println("Receive: " + message);
  7. return Action.CommitMessage;
  8. }
  9. });
  10. consumer.start();

Code of JVM-2

  1. Properties properties = new Properties();
  2. properties.put(PropertyKeyConst.ConsumerId, "CID-MQ-FAQ");
  3. Consumer consumer = ONSFactory.createConsumer(properties);
  4. consumer.subscribe("MQ-FAQ-TOPIC-1", "NM-MQ-FAQ", new MessageListener() {
  5. public Action consume(Message message, ConsumeContext context) {
  6. System.out.println("Receive: " + message);
  7. return Action.CommitMessage;
  8. }
  9. });
  10. consumer.start();

Possible reason 2

Topics are same, but Tags are different.

Example

Consumer ID, CID-MQ-FAQ, subscribes to a Topic with two Tags, NM-MQ-FAQ-1 and NM-MQ-FAQ-2.

Code of JVM-1

  1. Properties properties = new Properties();
  2. properties.put(PropertyKeyConst.ConsumerId, "CID-MQ-FAQ");
  3. Consumer consumer = ONSFactory.createConsumer(properties);
  4. consumer.subscribe("MQ-FAQ-TOPIC-1", "NM-MQ-FAQ", new MessageListener() {
  5. public Action consume(Message message, ConsumeContext context) {
  6. System.out.println("Receive: " + message);
  7. return Action.CommitMessage;
  8. }
  9. });
  10. consumer.start();

Code of JVM-2

  1. Properties properties = new Properties();
  2. properties.put(PropertyKeyConst.ConsumerId, "CID-MQ-FAQ");
  3. Consumer consumer = ONSFactory.createConsumer(properties);
  4. consumer.subscribe("MQ-FAQ-TOPIC-2", "NM-MQ-FAQ", new MessageListener() {
  5. public Action consume(Message message, ConsumeContext context) {
  6. System.out.println("Receive: " + message);
  7. return Action.CommitMessage;
  8. }
  9. });
  10. consumer.start();

Solution

Follow the following steps:

  1. Check the code of clients, ensuring Consumer ID subscription consistency in terms of Topic and Tag.

  2. Resart all the applications.

Result

  • Consumers can receive all the expected messages.

  • Log on MQ console. Click Consumers > Consuemr Status. The bar of Subscirption Consistency shows Yes.

Thank you! We've received your feedback.