Read JMS queue with out delete - Websphere

This is a discussion on Read JMS queue with out delete - Websphere ; Hi, AM using the below code for reading messages from JMS queue. But here queueReceiver.receive is deleteing the messages after reading the content.But in my case need to read the content and the message need to be there.Can some one ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Read JMS queue with out delete

  1. Read JMS queue with out delete

    Hi,


    AM using the below code for reading messages from JMS queue.
    But here queueReceiver.receive is deleteing the messages after reading the content.But in my case need to read the content and the message need to be there.Can some one please post the code for my requirment.


    queueConnection =
    queueConnectionFactory.createQueueConnection();
    queueSession =
    queueConnection.createQueueSession(false,
    Session.AUTO_ACKNOWLEDGE);
    queueReceiver = queueSession.createReceiver(queue);
    queueConnection.start();
    while (true) {
    Message m = queueReceiver.receive(1);
    if (m != null) {
    if (m instanceof TextMessage) {
    message = (TextMessage) m;
    System.out.println("Reading message: " +
    message.getText());
    } else {
    break;
    }
    }
    }

    Cheers,
    jo

  2. Re: Read JMS queue with out delete

    QueueBrowser rather than QueueReceiver?
    //S

+ Reply to Thread