messagingStats.getInboundExchanges().increment(); messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime);
if (container.isNotifyStatistics()) { long oldCount = messagingStats.getInboundExchanges().getCount(); messagingStats.getInboundExchanges().increment(); componentConnector.getComponentMBean().firePropertyChanged( "inboundExchangeCount", new Long(oldCount), new Long(messagingStats.getInboundExchanges().getCount())); double oldRate = messagingStats.getInboundExchangeRate().getAverageTime(); messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime); componentConnector.getComponentMBean().firePropertyChanged("inboundExchangeRate", new Double(oldRate), new Double(messagingStats.getInboundExchangeRate().getAverageTime())); } else { messagingStats.getInboundExchanges().increment(); messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime); }
    public void processInBound(MessageExchangeImpl me) throws MessagingException {        checkNotClosed();        long currentTime = System.currentTimeMillis();        messagingStats.getInboundExchanges().increment();        messagingStats.getInboundExchangeRate().addTime(currentTime - lastReceiveTime);        lastReceiveTime = currentTime;        // If the message has been sent synchronously        // this is the answer, so update the syncState and notify the waiter        // Here, we don't need to put the message in the queue        MessageExchangeImpl theOriginal = (MessageExchangeImpl) exchangesById.get(me.getExchangeId());        if (theOriginal != null && theOriginal.getSyncState() == MessageExchangeImpl.SYNC_STATE_SYNC_SENT &&        	theOriginal.getRole() == me.getRole()) {            suspendTx(theOriginal);            synchronized (theOriginal) {                theOriginal.copyFrom(me);                theOriginal.setSyncState(MessageExchangeImpl.SYNC_STATE_SYNC_RECEIVED);                theOriginal.notify();            }        } else {            Component component = ((LocalComponentConnector) componentConnector).getComponent();            // If the component implements the MessageExchangeListener,            // the delivery can be made synchronously, so we don't need            // to bother about transactions            if (component != null && component instanceof MessageExchangeListener) {                me.handleAccept();                ((MessageExchangeListener) component).onMessageExchange(me);            }            else {                // Component uses async delivery                try {                    if (me.isTransacted() && me.getStatus() == ExchangeStatus.DONE) {                        // Do nothing in this case                    } else if (me.isTransacted() && me.getMirror().getSyncState() == MessageExchangeImpl.SYNC_STATE_ASYNC) {                        suspendTx(me);                        synchronized (me.getMirror()) {                            me.getMirror().setSyncState(MessageExchangeImpl.SYNC_STATE_SYNC_SENT);                            if (log.isDebugEnabled()) {                                log.debug("Queuing: " + me.getExchangeId() + " in " + this);                            }                            queue.put(me);                            if (log.isDebugEnabled()) {                                log.debug("Waiting: " + me.getExchangeId() + " in " + this);                            }                            // If the channel is closed while here,                            // we must abort                            waiters.put(Thread.currentThread(), Boolean.TRUE);                            try {                                me.getMirror().wait();                            } finally {                                waiters.remove(Thread.currentThread());                            }                            if (log.isDebugEnabled()) {                                log.debug("Notified: " + me.getExchangeId() + " in " + this);                            }                        }                        resumeTx(me);                    } else {                        suspendTx(me);                        queue.put(me);                    }                } catch (InterruptedException e) {                    throw new MessagingException(e);                }            }        }    }