Relationship Between Application Process, Consumer Group, and Consumer Instance
A consumer group may consist of multiple consumer instances.
A consumer group must have different consumer instances in the same process.
If you create the same consumer instance for different processes, two identical instances may be assigned to the same queue, and may not be assigned to some queues.
If you create the same consumer instance (such as instance A) for different processes, the two identical instances are connected to Q1 and Q2, but are not connected to Q3 and Q4.
The instance name is specified when a consumer is created and must be unique in the same consumer group for different processes. Alternatively, the instance name can be ignored when a consumer is created. RocketMQ will create a unique instance name (JAVA SDK) in the format of groupName|ip|pid|thread id|uuid.
Consistent Subscription Relationship for Consumers in the Same Group
For most distributed applications, a consumer group in RocketMQ. usually consists of multiple consumer instances. Consistent subscription relationship: all consumer instances in the same consumer group must have the exact same subscription to the Topic and Tag. If the subscription relationship is not consistent, it can cause confusion when consuming messages and may even result in message loss.
The subscription relationship mainly consists of Topic+Tag. To ensure that subscriptions are consistent, all consumer instances in the same consumer group must be consistent in the following aspects:
1. Subscribed topics must be consistent;
2. Tags in subscribed topics must be consistent.
Creating and Destroying Instances
1. Create an instance using CTGFactory [Compulsory Specifications].
2. A consumer is a heavyweight instance and consumes system resources upon each creation and destruction. You are advised to create a consumer during system startup and disable it upon system quit. It is not allowed to create new instances when messages are being consumed [Compulsory Specifications].
Consumption of Multiple Consumer Groups
The messages in a topic can be consumed by multiple consumer groups, each of which saves the progress independently on the server.
In a cluster, multiple consumers evenly consume topic messages. However, different programs are developed and debugged by multiple developers. The messages may be consumed by other program consumers in the same group during debugging and this situation should be avoided.
Reset Offset
You can reset the offset by time on the Console but the client must be offline.
Accumulation Volume
Consumption under a large number of accumulated messages is not recommended. You are advised to take the following measures to avoid massive message accumulation:
(1) Producing while consuming messages. If the consumption falls behind production, add consumers.
(2) Always keeping the consumers online. It is recommended to put the consumers online when the production starts.