Connecting to remote activemq instance running on docker container
I have 2 docker containers, one running a spring app (in tomcat) and one running an active mq instance. When I try to connect to it from my spring app, I get the following error. Only activeMQ is running on the one container and the port is properly exposed. I verified the IP address of the docker container (shown below) and that is correct.
I’m not sure what could be causing this error at this point. Any thoughts would be appreciated.
ERROR [activemq.broker.BrokerService] Failed to start Apache ActiveMQ ([mybroker, ID:489af431756c-60313-1409695404227-0:1], java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://172.17.0.2:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Cannot assign requested address)
One Solution collect form web for “Connecting to remote activemq instance running on docker container”
You configured Spring to start a broker service on 172.17.0.2, which is the IP of the remote machine. Instead, you should configure Spring to connect to an existing broker on that machine. From the ActiveMQ documentation and using the Spring facility JMSTemplate:
<!-- a pooling based JMS provider --> <bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL"> <value>tcp://activemq-host.local:61616</value> </property> </bean> </property> </bean> <!-- Spring JMS Template --> <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref local="jmsFactory"/> </property> </bean>