Tag Matching

Last updated: 2020-03-27 17:31:23

PDF

CMQ's Topic mode supports the subscription filter tag (tag) function, similar to rabbitMQ's direct_routing mode, which is provided in the next iteration. Because of the complexity of the strategy of using filter tags, this paper will explain it in combination with different scenarios.

Scene description

  • Scenario 1
    There are four subscribers A, B, C, and DMaga message tags are apple,B message tags are xiaomi,C and the message tags are imac+xiaomi,D without any tags.
    At this time, there are 100 messages from the producer publish to Topic, with message tags filtered as: apple, imac, iphone, macbook. After that, Topic immediately went to A, B, C and D by shipping.

Scene analysis :

Subscriber Message label Message receiving instructions
A Apple Because the apple can match the apple, in the message filter tag, it can receive 100 messages normally.
B Xiaomi I can't get any messages.
C Imac+xiaomi Because one of the tags imac can match, 100 messages can be received normally.
D - I can't get any messages.
  • Scenario 2
    Topic has and only four subscribers A, B, C, D, and none of the four subscribers have set up the message tag.
    At this time, there are 100 messages from the producer publish to Topic, with message tags filtered as: apple, imac, iphone, macbook. After that, Topic immediately went to A, B, C and D by shipping.

Scene analysis :
Subscribers A, B, C, D do not have tag, then shipping does not need to match messages, A, B, C, D can receive these 100 messages.

  • Scenario 3
    Topic has one and only one subscriber AMagi A whose subscription tag is set to xiaomi.
    At this time, there are 100 messages from the producer publish to Topic, with message tags filtered as: apple, imac, iphone, macbook. After that, Topic immediately went to A by shipping.

Scene analysis :

  • For subscriber A, if the subscription label does not match, A cannot receive the 100 messages. At this time, the 100 messages will be discarded immediately, and heap will not be in CMQ.

  • When the producer publish goes to Topic, the message filtering tag can only be set once before the publish. It is bound to the message ID and cannot be modified.

  • Scenario 4
    Topic named test1, at 12:01, called the API, that subscribed to publish to define the operation as "publish test1". After publish, shipping went to the subscribers and sent 200 messages to the A, B and C subscribers shipping.
    Suppose that 100 messages failed to receive in A, 30 messages failed in B, and all 200 messages in C were received successfully.

Scene analysis :

  • Message Retention Among the three subscribers A, B and C, it is assumed that the total number of failed messages for shipping is 110 (A has 100 failed messages, B has 30 failed messages, C is all successful, and the failed messages among the three are Interlaced's part). As long as there is a Associate relationship between any subscriber and a message, the message will not be unsubscribed immediately.
  • Blocking strategy Take A as an example, Topic shipping sent 200 messages to A, and when Article 101 failed, shipping of the following 99 would be blocked. The status is that 100 messages failed to receive.
  • Retry strategy (Backoff retry) Topic-test1 will repeat shipping message to A every N seconds. Of the 100 failed items, try again from the first one in order. If you fail three times, you will discard it directly. Then shipping's next message will be discarded again after three failures, in order.
  • Retry strategy (decline index retry) Take A as an example, Topic will send Concurrence shipping 100 messages (no guarantee of priority) when the subscriber fails to receive the first message, try again from the first message, and continue to block if it fails. The subsequent addition of shipping news will continue to block.
  • Message life cycle cannot be extended Suppose these 110messages about heap in Topic-test1, no matter how many times they are retried, have a life cycle of 1 day. Point in time, who is pushed from the producer to Topic, point in time, as the beginning and end, will be deleted when it expires.
  • Re-push Producers keep producing new messages in Topic. At 12:02, customers call the API, that subscribes to publish plus 110 messages from previous failed heap. Suppose there are 110 (failed heap) + 100 (new messages within 1 minute) = 210 messages in Topic. Shipping again. At this time, the retry strategy of A and B is decline index retry, and if they are in a state of "loss of contact", the 210messages will continue heap. For C, only 100 new messages are received.

The ID, of each message as key,value is Associate's subscriber, representing the success of each subscriber's consumption.

  • Scenario 5
    At 12:01, Topic, named test2, called the API, that subscribed to publish to define the operation as "publish test2" and sent 200 messages to A, B and C subscribers shipping.
    The hypothetical result is that all 200 messages of A, B and C are received successfully.

Scene analysis :
If Topic-test2, has and only has three subscribers A, B and C, and all of them confirm that the consumption is successful, Topic will delete 200 messages immediately.

Law summary

Through the above different scenarios, the tag matching rules are as follows:

Subscriber Does the subscriber have tag or not? Is there any news, tag? Message receiving instructions
A Yes None The subscriber does not match and cannot receive the message.
B None Yes Shipping when the message does not need to match, subscribers can receive the message.
C Yes Yes Only if the two match, can you receive the message. Ntag M matching is supported. If the message has 10 tag, subscribers and 4 tag, and one tag can match each other, the subscriber can receive the message.
D None None After shipping, all subscribers can receive the message.