title: MDB subscribing to remote jms topic in Apache Tomee
body: <p>I'm trying out Apache Tomee (1.5 plus) for the first time and I'm totally stuck at the moment.</p>
  
  <p>The company I work for have an application (using JBoss and HornetQ) that sends messages to a JMS topic, topic/theTopicsName.</p>
  
  <p>I'm trying to implement another service using Tomee/ActiveMQ that subscribes to said topic, usually from another computer to handle the messages in an MDB, but I can't get it to listen other than to localhost.</p>
  
  <p>If I've understood correctly it should be possible to add something like</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter"&gt;
      BrokerXmlConfig =
      ServerUrl       =  tcp://thehostname:5455
  &lt;/Resource&gt;
  
  &lt;Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory"&gt;
      ResourceAdapter = MyJmsResourceAdapter
  &lt;/Resource&gt;
  </code></pre>
  
  <p>In my /conf/tomee.xml</p>
  
  <p>Question is how do I go about make my MDB use the settings above? Is it possible through annotations or ejb-jar.xml?</p>
  
  <p>Say I have a simple MDB</p>
  
  <pre class="lang-java prettyprint-override"><code>public class MessageListenerMDB implements MessageListener {
  
      private ConnectionFactory connectionFactory;
  
      public MessageListenerMDB() {}
  
      public void onMessage(Message message) {
          //print message
      }
  }
  </code></pre>
  
  <p>And my */WEB_INF/ejb-jar.xml looks like</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true"&gt;
    &lt;enterprise-beans&gt;
      &lt;message-driven&gt;
        &lt;ejb-name&gt;MessageListenerMDB&lt;/ejb-name&gt;
        &lt;ejb-class&gt;my.package.jms.MessageListenerMDB&lt;/ejb-class&gt;
        &lt;messaging-type&gt;javax.jms.MessageListener&lt;/messaging-type&gt;
        &lt;activation-config&gt;
          &lt;activation-config-property&gt;
            &lt;activation-config-property-name&gt;
              destinationType
            &lt;/activation-config-property-name&gt;
            &lt;activation-config-property-value&gt;
              javax.jms.Topic
            &lt;/activation-config-property-value&gt;
          &lt;/activation-config-property&gt;
          &lt;activation-config-property&gt;
            &lt;activation-config-property-name&gt;
              destination
            &lt;/activation-config-property-name&gt;
            &lt;activation-config-property-value&gt;
              /topic/theTopicsName
            &lt;/activation-config-property-value&gt;
          &lt;/activation-config-property&gt;
        &lt;/activation-config&gt;
  
        &lt;resource-ref&gt;
          &lt;res-ref-name&gt;
            java:comp/env/my.package.jms.MessageListenerMDB/connectionFactory
          &lt;/res-ref-name&gt;
          &lt;res-type&gt;javax.jms.ConnectionFactory&lt;/res-type&gt;
          &lt;injection-target&gt;
            &lt;injection-target-class&gt;
              my.package.jms.MessageListenerMDB
            &lt;/injection-target-class&gt;
          &lt;injection-target-name&gt;connectionFactory&lt;/injection-target-name&gt;
        &lt;/injection-target&gt;
      &lt;/resource-ref&gt;
  
      &lt;/message-driven&gt;
    &lt;/enterprise-beans&gt;
  &lt;/ejb-jar&gt;
  </code></pre>
  
  <p>What do I have to do to make it use the ConnectionFactory above?
  Am I totally wrong from the beginning?</p>
  
  <p>Friendly regards /Magnus</p>