activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: Active MQ 3.2.1 QueueSender
Date Tue, 11 Jul 2006 15:54:09 GMT
do you get any exceptions?

On 7/10/06, avin98 <avin98@yahoo.com> wrote:
>
>
> When you try to send a message to a queue in ActiveMQ 3.2.2 (bundled along
> with geronimo), it doesn't work the first time.
>
> Why is this ??? I faced the same problem with the samples as well, when I
> try to send message from a servlet.
>
> Here is the code snippet that does that:
>
>         QueueSession session = null;
>         QueueSender sender = null;
>         TextMessage message = null;
>         String correlationId = null;
>         QueueConnection connection = null;
>         String connectionFactoryName = "java:comp/env/jms/broker";
>         String queueName = "java:comp/env/jms/queue/OutboundQueue";
>         try {
>
>             InitialContext naming = new InitialContext();
>
>             // lookup queue connection factory
>             QueueConnectionFactory connectionFactory =
> (QueueConnectionFactory) naming
>                 .lookup(connectionFactoryName);
>
>             // create jms connection
>             connection = connectionFactory
>                 .createQueueConnection();
>
>             // System.out.println("Connection is:"+ connection);
>
>             // lookup jms queue
>             Queue queue = (Queue) naming.lookup(queueName);
>
>             // create a session.
>             session = connection.createQueueSession(false,
>                 Session.AUTO_ACKNOWLEDGE);
>
>             // create a QueueSender
>             sender = session.createSender(queue);
>             sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
>             // create a message to send to the queue...
>             message = session.createTextMessage();
>
>             message.setText(dataStream);
>
>
>             // send
>             sender.send(message);
>
>             // store the messageID as correlationID
>             correlationId = message.getJMSMessageID();
>
>
>
>         } catch (Exception je) {
>             je.printStackTrace();
>
>         } finally {
>             try {
>                 if (sender != null)
>                     sender.close();
>                 if (session != null)
>                     session.close();
>                 if(connection !=null)
>                     connection.close();
>              } catch (JMSException je) {
>                 je.printStackTrace();
>
>             }
>         }
>
> --
> View this message in context:
> http://www.nabble.com/Active-MQ-3.2.1-QueueSender-tf1920777.html#a5259006
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message