Example usage for org.springframework.integration MessageTimeoutException MessageTimeoutException

List of usage examples for org.springframework.integration MessageTimeoutException MessageTimeoutException

Introduction

In this page you can find the example usage for org.springframework.integration MessageTimeoutException MessageTimeoutException.

Prototype

public MessageTimeoutException(Message<?> failedMessage, String description) 

Source Link

Usage

From source file:org.springframework.integration.jms.JmsOutboundGateway.java

@Override
protected Object handleRequestMessage(final Message<?> requestMessage) {
    if (!this.initialized) {
        afterPropertiesSet();//from  w w w  . j  a v a  2  s  .co  m
    }
    try {
        Object reply;
        if (this.replyContainer == null) {
            reply = sendAndReceiveWithoutContainer(requestMessage);
        } else {
            if (this.idleReplyContainerTimeout > 0) {
                synchronized (this.lifeCycleMonitor) {
                    this.lastSend = System.currentTimeMillis();
                    if (!this.replyContainer.isRunning()) {
                        if (logger.isDebugEnabled()) {
                            logger.debug(this.getComponentName() + ": Starting reply container.");
                        }
                        this.replyContainer.start();
                        this.idleTask = getTaskScheduler().scheduleAtFixedRate(new IdleContainerStopper(),
                                this.idleReplyContainerTimeout / 2);
                    }
                }
            }
            reply = this.sendAndReceiveWithContainer(requestMessage);
        }
        if (reply == null) {
            if (this.requiresReply) {
                throw new MessageTimeoutException(requestMessage,
                        "failed to receive JMS response within timeout of: " + this.receiveTimeout + "ms");
            } else {
                return null;
            }
        }

        if (reply instanceof javax.jms.Message) {
            return buildReply((javax.jms.Message) reply);
        } else {
            return reply;
        }
    } catch (JMSException e) {
        throw new MessageHandlingException(requestMessage, e);
    }
}