I have 2 applications:
1 application uses ElasticMq queue for listening to the messages.
The 2nd application publishes the messages on an SNS topic.
I am able to subscribe to the ElasticMq queue on the SNS topic. But when I publish on the topic local stack is unable to send the message to elasticmq eventhough subscription was successful.
awslocal sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:123456789012:classification-details-topic
{
    "Subscriptions": [
        {
            "SubscriptionArn": "arn:aws:sns:us-east-1:123456789012:classification-details-topic:ea470c5a-c352-472e-9ae0-a1386044b750",
            "Owner": "",
            "Protocol": "sqs",
            "Endpoint": "http://elasticmq-service:9324/queue/test",
            "TopicArn": "arn:aws:sns:us-east-1:123456789012:classification-details-topic"
        }
    ]
}
Below is the error message I receive:
awslocal sns publish --topic-arn arn:aws:sns:us-east-1:123456789012:classification-details-topic --message "My message"
An error occurred (InvalidParameter) when calling the Publish operation: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the SendMessage operation: AWS.SimpleQueueService.NonExistentQueue; see the SQS docs.
Am I wrong in having elasticmq subscribed on local stack?
I am running localstack using docker-compose file
version: '2.1'
services:
  localstack:
    image: localstack/localstack
    ports:
      - "4567-4584:4567-4584"
      - "${PORT_WEB_UI-8001}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
networks:
  default:
    external:
      name: my_network
I have the elasticmq and other services as a part of different docker-compose using the same docker network "my_network"
The below is the complete docker-compose. I tried reproducing it by combining the entries into one docker-compose file.
Steps to reproduce
version: '3'
services:
  elasticmq:
    build: ./elasticmq
    ports:
      - '9324:9324'
    networks:
      - my_network
    dns:
      - 172.16.198.101
  localstack:
    image: localstack/localstack
    ports:
      - "4567-4584:4567-4584"
      - "${PORT_WEB_UI-8001}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
    links:
      - elasticmq:elasticmq-service
    networks:
      - my_network
    dns:
      - 172.16.198.101
networks:
  my_network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.16.198.0/24
After this one can run the following set of commands
awslocal sqs create-queue --queue-name test --endpoint http://elasticmq:9324/
awslocal sns create-topic --name test-topic
awslocal sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:test-topic --protocol sqs --notification-endpoin http://elasticmq-service:9324/queue/test
 
    
