title: How to connect a remote jms client to an embedded activemq broker in tomcat?
body: <p>I have an embedded broker in tomcat that my webapp clients are connecting to fine using vm://localhost.  I would like some remote clients in another jvm be able to connect to the embedded broker.  How do I set up the embedded broker to listen on a port#?  This works for embedded clients: </p>
  
  <p>server.xml fragment: </p>
  
  <pre><code>&lt;Resource auth="Container" 
  name="jms/ConnectionFactory" 
  type="org.apache.activemq.ActiveMQConnectionFactory" 
  description="JMS Connection Factory" 
  factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
  brokerURL="vm://localhost" 
  brokerName="MyActiveMQBroker" 
  useEmbeddedBroker="true"/&gt;  
  </code></pre>
  
  <p>This isn't working for remote clients, but my embedded clients still connect using vm://localhost: </p>
  
  <pre><code>&lt;Resource auth="Container" 
  name="jms/ConnectionFactory" 
  type="org.apache.activemq.ActiveMQConnectionFactory" 
  description="JMS Connection Factory" 
  factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
  brokerURL="vm:(broker:(tcp://localhost:61616))" 
  brokerName="MyActiveMQBroker" 
  useEmbeddedBroker="true"/&gt;  
  </code></pre>
  
  <p>My remote clients give this error: </p>
  
  <p>Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused </p>
  
  <p>I also have been trying this: </p>
  
  <pre><code>brokerURL="vm://localbroker?brokerConfig=xbean:file:C:/temp/activemq.xml"
  </code></pre>
  
  <p>and in the activemq.xml, setting this:</p>
  
  <pre><code>&lt;transportConnectors&gt;
  &lt;transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/&gt;
  &lt;/transportConnectors&gt;
  
  &lt;networkConnectors&gt;
  &lt;networkConnector uri="static:(tcp://0.0.0.0:61616)"/&gt;
  &lt;/networkConnectors&gt;
  </code></pre>
  
  <p>I don't believe the xml file is getting read, because my symptoms never change when editing it.  On tomcat startup, when the first client webapp deploys, the broker starts and reports that: </p>
  
  <p>Connector vm://localhost Started</p>
  
  <p>I never see another connector started, like tcp://0.0.0.0:61616.  Is this possible?</p>