Example usage for org.springframework.jms.core JmsTemplate setReceiveTimeout

List of usage examples for org.springframework.jms.core JmsTemplate setReceiveTimeout

Introduction

In this page you can find the example usage for org.springframework.jms.core JmsTemplate setReceiveTimeout.

Prototype

public void setReceiveTimeout(long receiveTimeout) 

Source Link

Document

Set the timeout to use for receive calls (in milliseconds).

Usage

From source file:org.openengsb.ports.jms.JMSOutgoingPort.java

@Override
protected String doFilter(String input, Map<String, Object> metaData) {
    String destination = (String) metaData.get("destination");
    String callId = (String) metaData.get("callId");
    LOGGER.info("sending message with callId {} to destination {}", callId, destination);
    sendMessage(destination, input);/*from  w w w .  j  a v  a 2s  .  c  om*/

    if (ObjectUtils.notEqual(metaData.get("answer"), true)) {
        LOGGER.debug("no answer expected, just returning null");
        return null;
    }
    LOGGER.info("waiting {}ms for response on call with id {}", timeout, callId);
    JmsTemplate createJMSTemplate = createJMSTemplate(destination);
    createJMSTemplate.setReceiveTimeout(timeout);
    Object receiveAndConvert = createJMSTemplate.receiveAndConvert(callId);
    if (receiveAndConvert == null) {
        throw new RuntimeException("JMS Receive Timeout reached");
    }
    LOGGER.info("response for call with id {} received", callId);
    return (String) receiveAndConvert;
}