DTodt
DTodt

Reputation: 380

Apache kafka message communication between microservices

I have a problem, that I want to solve using kafka queues. I need to process some result, then return it to the user.

enter image description here

As you can see in the picture, the Rest Service, requests something to the Calculator Service.

Both services have a kafka consumer, and a kafka producer.

Sometimes the rest service receives old messages from the queue, or more than one message. I find something about idempotent configuration, but I don't know how to implement right.

Is that diagram, the right way to the communication between two or more services using kafka?

Can someone give a example?

Thanks.

Upvotes: 1

Views: 1231

Answers (2)

miguno
miguno

Reputation: 15057

Is that diagram, the right way to the communication between two or more services using kafka?

If you mean "Does it make sense to have two or more services communicate indirectly through Kafka?", then yes, it does.

Can someone give a example?

Here are some good pointers including examples:

Upvotes: 3

Arek
Arek

Reputation: 3176

To answer your question: There is no problem with such communication.

Now referring back to other parts... Keep in mind that it's an asynchronous communication so you should not keep HTTP connection open and keep user of that service waiting for the response. This is just not the way to go. You can solve this in many ways. For instance: you can use WebSockets, you can send an email/SMS/slack msg to the user with the reply and so on.

Upvotes: 1

Related Questions