I have 500 sub-applications deployed on 500 different servers, as well as a main application, and now there is an MQ. My main application will send messages to the sub-application. There are many functions on the sub-application, all of which require different messages.
Should I open a consumer in the sub-application, or should I open a consumer for each function of the sub-application?
My current plan is to open only one consumer for each sub-application, and then define the specific method of operation in the message sent. The format is as follows:
{
"header": {
"action": "scan_address"
},
"body": {
"id": 1234,
"name": "xxxxxx"
}
}
When the sub-application gets the message, it decides which method to call based on the action. Then the body is the business data that needs to be processed.
In your case, you are using MQ to make loosely coupled RPC calls. I don't know what your mq selection is. For example, Kafka, which I am familiar with, can use a topic, and then configure a single consumer group on a single machine, and then write messages according to RPC. Basically, it can be done without duplication or loss, and the upstream and downstream services are decoupled.