I want to send a message to notify about something in one of my microservices, but I don't want to do that through a domain event, which requires to create, update or delete one of the entities of the microservice.
Is there another way to send a message such that another microservices can handle them?
Yes! You can do that directly using the
BrokerPublisher
instance injected in the corresponding service.If you want to send a message you can do as follows:
In this case,
"MyChannel"
refers to the channel (or topic) on which the message will be sent.Note that
MyContent
is a convenientModelType
created just to give the message's content some structure (but it could be another type, likeint
,str
,dict
and so on).Finally, if you want to handle it in another microservice, you can do that as any other message: