Example usage for javax.jms MessageProducer getDeliveryMode

List of usage examples for javax.jms MessageProducer getDeliveryMode

Introduction

In this page you can find the example usage for javax.jms MessageProducer getDeliveryMode.

Prototype


int getDeliveryMode() throws JMSException;

Source Link

Document

Gets the producer's default delivery mode.

Usage

From source file:org.apache.qpid.disttest.jms.ClientJmsDelegate.java

public Message sendNextMessage(final CreateProducerCommand command) {
    Message sentMessage = null;// www . j  av  a2  s .  c  om
    MessageProvider messageProvider = _testMessageProviders.get(command.getMessageProviderName());
    if (messageProvider == null) {
        messageProvider = _defaultMessageProvider;
    }

    final Session session = _testSessions.get(command.getSessionName());
    final MessageProducer producer = _testProducers.get(command.getParticipantName());
    try {
        sentMessage = messageProvider.nextMessage(session, command);
        int deliveryMode = producer.getDeliveryMode();
        int priority = producer.getPriority();
        long ttl = producer.getTimeToLive();
        if (messageProvider.isPropertySet(MessageProvider.PRIORITY)) {
            priority = sentMessage.getJMSPriority();
        }
        if (messageProvider.isPropertySet(MessageProvider.DELIVERY_MODE)) {
            deliveryMode = sentMessage.getJMSDeliveryMode();
        }
        if (messageProvider.isPropertySet(MessageProvider.TTL)) {
            ttl = sentMessage.getLongProperty(MessageProvider.TTL);
        }
        producer.send(sentMessage, deliveryMode, priority, ttl);
    } catch (final JMSException jmse) {
        throw new DistributedTestException("Unable to create and send message with producer: "
                + command.getParticipantName() + " on session: " + command.getSessionName(), jmse);
    }
    return sentMessage;
}