Version 7

    Whether a message should be persisted when it is sent/published on the jms server. The options are:

    • Persistent - The message is persisted

    • NonPersistent - The message is not persisted

     

    NOTE: Persistent messages sent to a TemporaryQueue, TemporaryTopic or

    Non Durable Subscription are not persisted

     

    It is a common mistake to try to set it on the message. This has no effect.

    QueueSender sender = session.createSender(myQueue);
    Message message = session.createTextMessage("hello");
    int priority = 4;
    

     

    WRONG WAY:

    message.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // THIS DOES NOT WORK!
    sender.send(message);
    

     

    CORRECT WAY:

    sender.send(message, DeliveryMode.NON_PERSISTENT, priority, 0);