FileDocCategorySizeDatePackage
MessageSender.javaAPI DocGlassfish v2 API4095Fri May 04 22:30:28 BST 2007com.sun.enterprise.jbi.serviceengine.comm

MessageSender

public class MessageSender extends com.sun.enterprise.jbi.serviceengine.work.OneWork
An instance of this class is used to send a message to NMR. Messages can be send either using the caller's thread or in a new thread.
author
Binod PG
see
OneWork

Fields Summary
Constructors Summary
Methods Summary
public voiddoWork()
Actually send the message to NMR.

        try {
            if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST,
                "Sending the message " + getMessageExchange() + "to NMR");
            }
    
            boolean sendSync = shouldSendSync(getMessageExchange());

            if(sendSync) {
                getDeliveryChannel().sendSync(getMessageExchange());
            } else {
                getDeliveryChannel().send(getMessageExchange());
            }
            
            if (getMessageExchange().getStatus()== ExchangeStatus.ERROR &&
                    getMessageExchange().getRole().equals(MessageExchange.Role.CONSUMER))
                setException(getMessageExchange().getError());
            
            if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST, 
                "Sent message " + getMessageExchange() + "to NMR");
            }
        } catch (MessagingException me) {
            logger.log(Level.WARNING, "Error sending message" + me.getMessage());
            setException(me);
        }
    
public voidsend()
Users of this class execute send() method to send the message to NMR. Note that execute() method will finally call doWork().

        execute();
    
private booleanshouldSendSync(javax.jbi.messaging.MessageExchange exchange)


        if(exchange.getRole().equals(MessageExchange.Role.CONSUMER) &&
                exchange.getStatus().equals(ExchangeStatus.ACTIVE)) {
            return true;
        }

        return false;