Trying to send messages between Docker containers using rabbitmq
I’m currently experimenting with Docker and rabbitmq using the Java client, and I’m trying to figure out how to send a simple message i.e. “Hello world” between one container holding the Send class, to a second container running the rabbitmq server, and then to a third container holding the Receive class. Can anyone help with trying to set this up or if this isn’t actually possible?
So far what I’ve done is on the send and receive containers I’m running Ubuntu with Java installed and with the java client in the memory, and I have these both linked through the link command to the server container. On trying to run either class I get a number of “unable to connect” errors, and don’t know how to solve it. If anyone could help that would be great. Thanks!
I’m trying to run just the simple send and receive classes from the rabbitmq tutorial. For the send container the Dockerfile I’m using is
FROM ubuntu RUN apt-get update RUN apt-get install software-properties-common -y RUN add-apt-repository ppa:webupd8team/java -y RUN apt-get update RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections RUN apt-get install oracle-java8-installer -y RUN apt-get install oracle-java8-set-default ADD Send.class /usr/ ADD rabbitmq-java-client-bin-3.5.3.zip /usr/
And similar for the Receive container.
I’m starting the rabbitmq server container with
docker run --name server1 rabbitmq:3
then starting the send container with
docker run -i -t -d -P --name send --link server1 sendtest
Inside the send container I unzip the java client, then try to run the send class but get the connection refused error. I know there’s something I’m missing, just not sure what it is.
One Solution collect form web for “Trying to send messages between Docker containers using rabbitmq”
I have gotten this to work quite well using Docker Compose. If you want to use Docker run it should work too if you specify the ports in the rabbitMQ run. Something like
docker run –expose 5672 -P –name server1 rabbitmq:3