简体   繁体   中英

Message Bus/Queue in Microservices

We are planning to rewrite our backend of a bigger application.

One part of it is to use some kind of message bus or message queue system.

We are looking for a framework where the following code would work.

var topic = "products";
var mq = MessageQueueFactory.CreateMessageQueue(topic);
ProductInformation result = await mq.Publish(new ProductInformationSearchRequest(1337));
// work with the result

Something like that. I know it's kind of against the idea of the system to wait for the response in the same function where the request was issued.

There are some frameworks, that can answer to a session. But you would have a seperate Response-Queue.

Our goal is to send some information into a queue. The frameworks finds a destination to send the message to and after the destination responded i get my result back. Multiple destination (of the same kind) might exist. Not all requests need to be answered. Only thoose that are flaged to do so. A Message Broker or similar would be fine as well.

Is there something that exists, or do i have to build a wrapper around something? With this kind of architecture we can eliminate dependencies that some microservice have right now. Or do we even have to change our architecure for a system like this to work? Does this even makes sense?

Btw.: the old way was/is to use REST and an API-Gateway to communicate between the services.

Look at the temporal.io . It allows writing code that looks like a synchronous invocation, but internally is fully asynchronous, uses queues and preserves state of the invocation as long as necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM