Example usage for javax.jms MessageProducer getPriority

List of usage examples for javax.jms MessageProducer getPriority

Introduction

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

Prototype


int getPriority() throws JMSException;

Source Link

Document

Gets the producer's default priority.

Usage

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

public Message sendNextMessage(final CreateProducerCommand command) {
    Message sentMessage = null;/*from w  ww.  jav a 2 s . c o m*/
    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;
}