ActiveMQ Learning Notes (2) – JMS Message Model

1.1 Introduction to the JMS model

JMS supports two forms of message connections:

  • Point to point (P2P)

  • Publisher/subscriber form


    In the P2P model, the sender sends a message to a queue that can only be used by one client; Once the message is consumed, no other client can retrieve the message from this queue. There is only one piece of sugar in a packet of chocolate sugar. Only the person who opened the first can be eaten, and after that people cannot eat it.

    In the Pub/Sub model, the topic of the message (topic) can be listened to by multiple subscribers, and these subscribers can receive the message; Provided that the subscriber subscribes to this topic and can only accept the subsequent signature. Information. It’s like subscribing to a magazine in real life. We can only get the subsequent records. In the previous records, the records could not be delivered to us.

1.2 Point-to-point models

Each message has only one consumer. If this news is consumed, other consumers cannot accept the news.

News consumption has nothing to do with time. During the news transmission, before the news expires, if there are no other consumers consuming the news, the client can consume the news at any time.

After receiving the message, consumers must confirm with the message provider, otherwise it will be considered that the news is not consumed, and other consumers can still use it. You can set auto confirmation. This feature effectively ensures that a message can only be used by a single consumer.

  • Unstable news is sent only once

    Failed news may be lost due to message expiration andThe message provider may be down.

  • Perseverance News accurately published once

    The message can persist, for example, static in the file system or database, which can be avoidedMessage provider violations or other violations result in lost messages.

1.3 Publisher/Subscriber Model

  • Each post can have multiple subscribers

  • Subscribers can only consume it after the topic information

  • Unable to subscribe, subscribers must maintain active status in order to use these messages. If subscriber is off for 10 minutes, A will not receive news for those 10 minutes.

  • For ongoing subscriptions, the message provider will store these messages. Even if the subscriber is disconnected for network reasons, after reconnecting, you can spread the consumption news.

  • Usage of perpetual subscriptions should be evaluated according to business scenarios.

Leave a Comment