Example usage for org.springframework.amqp.support.converter SimpleMessageConverter DEFAULT_CHARSET

List of usage examples for org.springframework.amqp.support.converter SimpleMessageConverter DEFAULT_CHARSET

Introduction

In this page you can find the example usage for org.springframework.amqp.support.converter SimpleMessageConverter DEFAULT_CHARSET.

Prototype

String DEFAULT_CHARSET

To view the source code for org.springframework.amqp.support.converter SimpleMessageConverter DEFAULT_CHARSET.

Click Source Link

Usage

From source file:org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.java

/**
 * Post-process the given response message before it will be sent.
 * <p>//w ww. j  av a 2 s  .  c o  m
 * The default implementation sets the response's correlation id to the request message's correlation id, if any;
 * otherwise to the request message id.
 * @param request the original incoming Rabbit message
 * @param response the outgoing Rabbit message about to be sent
 * @throws Exception if thrown by Rabbit API methods
 */
protected void postProcessResponse(Message request, Message response) throws Exception {
    byte[] correlation = request.getMessageProperties().getCorrelationId();

    if (correlation == null) {
        String messageId = request.getMessageProperties().getMessageId();
        if (messageId != null) {
            correlation = messageId.getBytes(SimpleMessageConverter.DEFAULT_CHARSET);
        }
    }
    response.getMessageProperties().setCorrelationId(correlation);
}