Esempio n. 1
0
 /**
  * @param queueName
  * @param message
  * @throws Exception
  */
 public static void sendMessage(String queueName, Message message) throws Exception {
   MessageProducer producer = (MessageProducer) producerPool.borrowObject(queueName);
   try {
     producer.send(message);
   } finally {
     producerPool.returnObject(queueName, producer);
   }
 }
Esempio n. 2
0
 /**
  * Create a TextMessage destined for the specified queue.
  *
  * @param queueName the name of the destination queue
  * @param message the message text
  * @return a TextMessage object
  * @throws Exception thrown if an exception occurs
  */
 public static TextMessage createTextMessage(String queueName, String message) throws Exception {
   Session jmsSession = (Session) sessionPool.borrowObject(queueName);
   try {
     return jmsSession.createTextMessage(message);
   } finally {
     sessionPool.returnObject(queueName, jmsSession);
   }
 }
Esempio n. 3
0
    /** {@inheritDoc} */
    @Override
    public Object makeObject(Object key) throws Exception {
      Session jmsSession = (Session) sessionPool.borrowObject(key.toString());
      try {
        // Create the destination (Topic or Queue)
        Destination destination = jmsSession.createTopic(key.toString());

        // Create a MessageProducer from the Session to the Topic or Queue
        MessageProducer producer = jmsSession.createProducer(destination);
        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

        return producer;
      } finally {
        sessionPool.returnObject(key.toString(), jmsSession);
      }
    }