Java Code Examples for javax.jms.Message.getJMSPriority()

The following are Jave code examples for showing how to use getJMSPriority() of the javax.jms.Message class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jaffa-framework   File: JmsClientHelper.java   Source Code and License Vote up 6 votes
/** Writes a JMS Message to the destination, as defined in the configuration file.
 * @param session the JMS Session.
 * @param message the JMS Message.
 * @param destinationName the Destination to write to.
 * @throws FrameworkException Indicates some system error.
 * @throws ApplicationExceptions Indicates application error(s).
 */
static void send(Session session, Message message, String destinationName) throws FrameworkException, ApplicationExceptions {
    try {
        Destination destination = obtainDestination(destinationName);
        MessageProducer producer = session.createProducer(destination);
        int messagePriority = message.getJMSPriority();
        if (messagePriority != producer.getPriority() && messagePriority >= 0 && messagePriority <= 9)
            producer.setPriority(messagePriority);
        producer.send(message);
        if (log.isDebugEnabled())
            log.debug("Sent message " + message + " to " + destinationName);
    } catch (JMSException e) {
        log.error("Error in sending a JMS Message", e);
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.SEND_ERROR, null, e);
    }
}