title: How would i create an ActiveMQ Producer programatically in Java for Mule?
body: <p>I got a doubt about this, i've created an ActiveMQ Connector with its Connector-Reference as well:</p>
  
  <pre><code>&lt;jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="false"  doc:name="Active MQ" &gt;
      &lt;reconnect count="5"  /&gt;
  &lt;/jms:activemq-connector&gt;
  </code></pre>
  
  <p>I know i can get this by doing from Java: </p>
  
  <pre><code>Connector amqConnector = eventContext.getMuleContext().getRegistry().lookupConnector("Active_MQ");
  </code></pre>
  
  <p>But how would i create the producer by using this connector data and not by using JNDI? All the tutorials i've read they use the InitialContext getting the JNDI props by doing lookup().</p>
  
  <p>Also, in my ActiveMQ Config File i'm creating the queue. So the Queue its already created, i only need the producer to access to that Queue and not create it.</p>
  
  <p>And would my queueName be in the ActiveMQConnection "DestinationSource"? How do i get the queue names or info inside the activemq config file from Java? </p>
  
  <p>///// ADDED AFTER DAVID'S HELP:</p>
  
  <p>This is what i currently have:</p>
  
  <pre><code>@Override
      public Object onCall(MuleEventContext eventContext) throws Exception {
          String payload = eventContext.getMessage().getPayloadAsString();
          JmsConnector amqConnector = (JmsConnector) eventContext.getMuleContext().getRegistry().lookupConnector("Active_MQ");
          ConnectionFactory factory = amqConnector.getConnectionFactory();
          Connection connection; 
  
          connection = factory.createConnection();
  
          try {
              connection.start();
              Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              Queue queue = session.createQueue("ExampleQueue");
  
              MessageProducer producer = session.createProducer(queue);           
              producer.send(session.createTextMessage(payload), DeliveryMode.NON_PERSISTENT, 0, 5000);
  
          }finally {
              connection.close();
          }
  
          return eventContext;
      }
  </code></pre>
  
  <p>Thanks in advance,</p>