title: Publishing message on JMS queue?
body: <p>i am new to JMS and going thru the example of  <a href="http://activemq.apache.org/hello-world" rel="nofollow">Active MQ Hello world</a>. Say i have a scenario whenever i make entry
  under employee table in DB, i have to put the message in queue.here is the producer code snippet from hello world example</p>
  
  <pre><code>public static class HelloWorldProducer  {
          public void createMessageOnQueue() {
              try {
                  // Create a ConnectionFactory
                  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
  
                  // Create a Connection
                  Connection connection = connectionFactory.createConnection();
                  connection.start();
  
                  // Create a Session
                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
                  // Create the destination (Topic or Queue)
                  Destination destination = session.createQueue("TEST.FOO");
  
                  // Create a MessageProducer from the Session to the Topic or Queue
                  MessageProducer producer = session.createProducer(destination);
                  producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
  
                  // Create a messages
                  String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode();
                  TextMessage message = session.createTextMessage(text);
  
                  // Tell the producer to send the message
                  System.out.println("Sent message: "+ message.hashCode() + " : " + Thread.currentThread().getName());
                  producer.send(message);
  
                  // Clean up
                  session.close();
                  connection.close();
              }
              catch (Exception e) {
                  System.out.println("Caught: " + e);
                  e.printStackTrace();
              }
          }
      }
  </code></pre>
  
  <p>Now my question is if i close the connection and session, will it close the queue also? If yes,what will happen if message has  not been consumed yet?</p>
  
  <p>Second question is if i need to publish the message on same queue(i.e "TEST.FOO") second time , do i need to call <code>createMessageOnQueue</code> method second time. If yes, will it not create  new queue with <code>session.createQueue("TEST.FOO")?</code></p>