title: Request/Response Messaging for Cloudfoundry Apps with AWS SQS
body: <p>I want to use AWS SQS for communication between my microservices (and later possibly SNS). Each microservice can have multiple instances up.</p>
  
  <p>Currently I'm trying to implement the Request/Response pattern of message queues.<br>
  As I understand it, the normal way is to have one request queue, and pass a unique response queue per service instance.<br>
  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.</p>
  
  <p>My problem now comes with Cloudfoundry.</p>
  
  <p>How it should work:<br>
  Service A needs to request data from Service B.<br>
  There is one queue named <code>A-request-B</code>.<br>
  Service A starts with 6 instances.<br>
  Every instance creates its own queue: <code>B-response-A-instance[x]</code><br>
  Every request from an instance of A sends their response queue name in the request so response is routed to the correct queue.</p>
  
  <p>This is the only way I know to guarantee that the response from B gets to the correct instance of A.<br>
  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.<br>
  The only way to create a queue is via the command line. 
  So I would have to create these 6 response-queues manually beforehand.<br>
  And if I start a 7th instance of A, it will fail as it doesn't have its own response queue.</p>
  
  <p>I also tried using the <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-temporary-queues.html" rel="nofollow noreferrer">SQS temporary queues</a>, but they also work by creating queues dynamically which is not possible in Cloudfoundry.</p>
  
  <p>I'm currently stuck with SQS, so switching to kafka/rabbitmq or something else is not possible.</p>
  
  <p>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?</p>