We’ll start this article with a detailed look at RockeMQ’s MESSAGE consuming API.

Message consumption diagram

The RocketMQ consumer API is shown below:

The core class diagram is shown below.

MQAdmin

Some of MQ’s basic administrative functions, such as creating a Topic, are somewhat odd, and the consumer side should not need to inherit this interface. This class is described in detail in the message sending API section and will not be repeated again.

MQConsumer

MQ consumer, this interface is too simple to define and some common methods of its sub-interfaces can be extracted into the interface if needed.

Set<MessageQueue> fetchSubscribeMessageQueues(final String topic)
Copy the code

Gets all read queues allocated to this Topic.

MQPushConsumer

RocketMQ supports push and pull modes. This interface defines the pull mode interface.

void start()
Copy the code

Start consumers.

void shutdown()
Copy the code

Turn off consumers.

void registerMessageQueueListen
Copy the code