title: Spring JMS - Unable to connect to broker URL with embedded Broker
body: <p>Here's my JmsMessageSender</p>
  
  <pre><code>@Service
  public class JmsMessageSender {
  
      @Autowired
      private JmsTemplate jmsTemplate;
  
  
      /**
       * send text to default destination
       * @param text
       */
      public void send(final String text) {
  
          this.jmsTemplate.send(new MessageCreator() {
              @Override
              public Message createMessage(Session session) throws JMSException {
                  Message message = session.createTextMessage(text);
                  return message;
              }
          });
      }
  
      /**
       * Simplify the send by using convertAndSend
       * @param text
       */
      public void sendText(final String text) {
          this.jmsTemplate.convertAndSend(text);
      }
  
      /**
       * Send text message to a specified destination
       * @param text
       */
      public void send(final Destination dest,final String text) {
  
          this.jmsTemplate.send(dest,new MessageCreator() {
              @Override
              public Message createMessage(Session session) throws JMSException {
                  Message message = session.createTextMessage(text);
                  return message;
              }
          });
      }
  }
  </code></pre>
  
  <p>Here's my DemoClass</p>
  
  <pre><code>public class DemoMain {
  
      public static void main(String[] args) {
          // init spring context
          ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
  
          // get bean from context
          JmsMessageSender jmsMessageSender = (JmsMessageSender)ctx.getBean("jmsMessageSender");
  
          // send to default destination
          jmsMessageSender.send("hello JMS");
  
          // send to a code specified destination
          Queue queue = new ActiveMQQueue("AnotherDest");
          jmsMessageSender.send(queue, "hello Another Message");
  
          // close spring application context
          ((ClassPathXmlApplicationContext)ctx).close();
      }
  
  }
  </code></pre>
  
  <p>My context.xml</p>
  
  <p>
      
      
  
  
  
      
  
  
  
  
  
  
      
      
  
  
  
      
      
  
  
      
      
  </p>
  
  <p>and my activemq.xml configuration.</p>
  
  <pre><code>&lt;beans
          xmlns="http://www.springframework.org/schema/beans"
          xmlns:amq="http://activemq.apache.org/schema/core"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"&gt;
  
      &lt;!-- Allows us to use system properties as variables in this configuration file --&gt;
      &lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="locations"&gt;
              &lt;value&gt;file:${activemq.conf}/credentials.properties&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!--
          The &lt;broker&gt; element is used to configure the ActiveMQ broker.
      --&gt;
      &lt;broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="activemq-data"&gt;
  
          &lt;!--
              For better performances use VM cursor and small memory limit.
              For more information, see:
  
              http://activemq.apache.org/message-cursors.html
  
              Also, if your producer is "hanging", it's probably due to producer flow control.
              For more information, see:
              http://activemq.apache.org/producer-flow-control.html
          --&gt;
  
          &lt;destinationPolicy&gt;
              &lt;policyMap&gt;
                  &lt;policyEntries&gt;
                      &lt;policyEntry topic="&gt;" producerFlowControl="true"&gt;
                          &lt;!-- The constantPendingMessageLimitStrategy is used to prevent
                               slow topic consumers to block producers and affect other consumers
                               by limiting the number of messages that are retained
                               For more information, see:
  
                               http://activemq.apache.org/slow-consumer-handling.html
  
                          --&gt;
                          &lt;pendingMessageLimitStrategy&gt;
                              &lt;constantPendingMessageLimitStrategy limit="1000"/&gt;
                          &lt;/pendingMessageLimitStrategy&gt;
                      &lt;/policyEntry&gt;
                      &lt;policyEntry queue="&gt;" producerFlowControl="true" memoryLimit="1mb"&gt;
                          &lt;!-- Use VM cursor for better latency
                               For more information, see:
  
                               http://activemq.apache.org/message-cursors.html
  
                          &lt;pendingQueuePolicy&gt;
                            &lt;vmQueueCursor/&gt;
                          &lt;/pendingQueuePolicy&gt;
                          --&gt;
                      &lt;/policyEntry&gt;
                  &lt;/policyEntries&gt;
              &lt;/policyMap&gt;
          &lt;/destinationPolicy&gt;
  
  
          &lt;!--
              The managementContext is used to configure how ActiveMQ is exposed in
              JMX. By default, ActiveMQ uses the MBean server that is started by
              the JVM. For more information, see:
  
              http://activemq.apache.org/jmx.html
          --&gt;
          &lt;managementContext&gt;
              &lt;managementContext createConnector="false"/&gt;
          &lt;/managementContext&gt;
  
          &lt;!--
              Configure message persistence for the broker. The default persistence
              mechanism is the KahaDB store (identified by the kahaDB tag).
              For more information, see:
  
              http://activemq.apache.org/persistence.html
          --&gt;
          &lt;persistenceAdapter&gt;
              &lt;kahaDB directory="activemq-data/kahadb"/&gt;
          &lt;/persistenceAdapter&gt;
  
  
          &lt;!--
            The systemUsage controls the maximum amount of space the broker will
            use before slowing down producers. For more information, see:
            http://activemq.apache.org/producer-flow-control.html
            If using ActiveMQ embedded - the following limits could safely be used:
  
        &lt;systemUsage&gt;
            &lt;systemUsage&gt;
                &lt;memoryUsage&gt;
                    &lt;memoryUsage limit="20 mb"/&gt;
                &lt;/memoryUsage&gt;
                &lt;storeUsage&gt;
                    &lt;storeUsage limit="1 gb"/&gt;
                &lt;/storeUsage&gt;
                &lt;tempUsage&gt;
                    &lt;tempUsage limit="100 mb"/&gt;
                &lt;/tempUsage&gt;
            &lt;/systemUsage&gt;
        &lt;/systemUsage&gt;
        --&gt;
          &lt;systemUsage&gt;
              &lt;systemUsage&gt;
                  &lt;memoryUsage&gt;
                      &lt;memoryUsage limit="64 mb"/&gt;
                  &lt;/memoryUsage&gt;
                  &lt;storeUsage&gt;
                      &lt;storeUsage limit="100 gb"/&gt;
                  &lt;/storeUsage&gt;
                  &lt;tempUsage&gt;
                      &lt;tempUsage limit="50 gb"/&gt;
                  &lt;/tempUsage&gt;
              &lt;/systemUsage&gt;
          &lt;/systemUsage&gt;
  
          &lt;!--
              The transport connectors expose ActiveMQ over a given protocol to
              clients and other brokers. For more information, see:
  
              http://activemq.apache.org/configuring-transports.html
          --&gt;
          &lt;transportConnectors&gt;
              &lt;!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --&gt;
              &lt;transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;amp;wireFormat.maxFrameSize=104857600"/&gt;
              &lt;transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;amp;wireFormat.maxFrameSize=104857600"/&gt;
          &lt;/transportConnectors&gt;
  
          &lt;!-- destroy the spring context on shutdown to stop jetty --&gt;
          &lt;shutdownHooks&gt;
              &lt;bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /&gt;
          &lt;/shutdownHooks&gt;
      &lt;/broker&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>However when I run my main class this error shows. Did I miss anything in the config?</p>
  
  <pre><code>Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.203.143:61616. Reason: java.net.ConnectException: Connection timed out: connect
  </code></pre>