I have a jar-packed application which starts tomcat with servlets on some port (e.g. 8080). Also I need to add activemq broker (client side) to this application, use it embedded with the same JVM.
I think I'll do it in code smt like
BrokerService broker = new BrokerService();
broker.setBrokerName("myBroker");
broker.addConnector("tcp://localhost:40001");
broker.start();
My question is do I have to start it on another port? Is there any possibility to start it on the same port on which webserver starts?
You can't do that because your application "binds" to the port and gets exclusive ownership of it. In purely logical terms how could the operating system otherwise know which application (Tomcat / ActiveMQ) to forward the request to?
In order to do what you need you must have another app called a "port multiplexer" bound as intermediary. Here's an example: https://github.com/joushou/serve2d
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments