I want to use AWS SQS for communication between my microservices (and later possibly SNS). Each microservice can have multiple instances up.
Currently I'm trying to implement the Request/Response pattern of message queues.
As I understand it, the normal way is to have one request queue, and pass a unique response queue per service instance.
The consuming service will process the message and send the response to the given response queue. Thus, the response will always be returned to the correct instance of the requesting service.
My problem now comes with Cloudfoundry.
How it should work:
Service A needs to request data from Service B.
There is one queue named A-request-B
.
Service A starts with 6 instances.
Every instance creates its own queue: B-response-A-instance[x]
Every request from an instance of A sends their response queue name in the request so response is routed to the correct queue.
This is the only way I know to guarantee that the response from B gets to the correct instance of A.
This doesn't work as Cloudfoundry doesn't allow the "create-queue" call from SQS, even if I can connect to the SQS instance to send and receive messages.
The only way to create a queue is via the command line.
So I would have to create these 6 response-queues manually beforehand.
And if I start a 7th instance of A, it will fail as it doesn't have its own response queue.
I also tried using the SQS temporary queues, but they also work by creating queues dynamically which is not possible in Cloudfoundry.
I'm currently stuck with SQS, so switching to kafka/rabbitmq or something else is not possible.
Is there any other way to pass a response to the matching service instance? Or is there another way to create queues in cloud foundry?
My problem now comes with Cloudfoundry.
-> I don't understand. Can you expand on this more? How are you creating your service? How are you consuming the service? What would you like to do, but can't? – Daniel MikusaThis doesn't work as Cloudfoundry doesn't allow the "create-queue" call from SQS
. Cloud Foundry doesn't really care what messaging system you're using. What about this causes it to fail? What error do you see? – Daniel Mikusacf create-service
to provision your SQS service. If that's a problem, you could always provision your own SQS service info & creds, that have the perms you need. Then create a user provided service with that info. You can bind it to your apps just like a service created by the AWS Service broker. You'd lose the convenience of using the broker, but you wouldn't have to jump through the hoops you listed when scaling up/down. – Daniel Mikusa