Example usage for org.springframework.amqp.core MessageProperties getReceivedExchange

List of usage examples for org.springframework.amqp.core MessageProperties getReceivedExchange

Introduction

In this page you can find the example usage for org.springframework.amqp.core MessageProperties getReceivedExchange.

Prototype

public String getReceivedExchange() 

Source Link

Usage

From source file:com.jbrisbin.vpc.jobsched.RequeueListener.java

@Override
public void onMessage(Message message, Channel channel) throws Exception {
    MessageProperties props = message.getMessageProperties();
    Map<String, Object> headers = props.getHeaders();
    int requeued = 0;
    if (headers.containsKey(REQUEUED)) {
        requeued = (Integer) headers.get(REQUEUED);
    }/*www.j  av a 2s . co m*/

    long delay = retryDelays[requeued];
    if (requeued < maxRetries) {
        headers.put(REQUEUED, requeued + 1);
        Object exchange = headers.get("exchange");
        if (null == exchange) {
            exchange = props.getReceivedExchange();
        } else {
            headers.remove("exchange");
        }
        Object route = headers.get("route");
        if (null == route) {
            route = props.getReceivedRoutingKey();
        } else {
            headers.remove("route");
        }
        log.info(String.format("Requeing message %s in %s...", new String(props.getCorrelationId()),
                convertMillis(delay)));
        timer.schedule(new DelayedSend(message, exchange.toString(), route.toString()), delay);
    }
}