Example usage for org.springframework.amqp.rabbit.listener.adapter MessageListenerAdapter setMessageConverter

List of usage examples for org.springframework.amqp.rabbit.listener.adapter MessageListenerAdapter setMessageConverter

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.listener.adapter MessageListenerAdapter setMessageConverter.

Prototype

public void setMessageConverter(MessageConverter messageConverter) 

Source Link

Document

Set the converter that will convert incoming Rabbit messages to listener method arguments, and objects returned from listener methods back to Rabbit messages.

Usage

From source file:org.resthub.rpc.RPCEndpoint.java

/**
 * Starts the endpoint on the connection specified.
 * A listener container is launched on a created queue. The listener will
 * respond to hessian requests. The endpoint is closed by calling the destroy 
 * method.//from  ww w.j av  a 2  s  .c  om
 */
public void run() {
    logger.debug("Launching endpoint for service : " + serviceAPI.getSimpleName());
    admin = new RabbitAdmin(connectionFactory);
    // Add connectionListener to recreate queue when connection fall
    connectionFactory.addConnectionListener(new ConnectionListener() {
        public void onCreate(Connection connection) {
            createQueue(admin, getRequestQueueName(serviceAPI));
        }

        public void onClose(Connection connection) {
        }

    });

    // Create the queue normaly the first time
    this.createQueue(admin, getRequestQueueName(serviceAPI));

    MessageListenerAdapter listenerAdapter = new MessageListenerAdapter(
            new RawMessageDelegate(serviceAPI, serviceImpl, serializationHandler));
    listenerAdapter.setMessageConverter(null);
    listenerAdapter.setMandatoryPublish(false);

    listenerContainer = new SimpleMessageListenerContainer();
    listenerContainer.setConnectionFactory(connectionFactory);
    listenerContainer.setQueueNames(getRequestQueueName(serviceAPI));
    listenerContainer.setMessageListener(listenerAdapter);
    if (this.concurentConsumers > 0) {
        listenerContainer.setConcurrentConsumers(concurentConsumers);
    }
    listenerContainer.start();
}

From source file:org.resthub.rpc.HessianEndpoint.java

/**
 * Starts the endpoint on the connection specified.
 * A listener container is launched on a created queue. The listener will
 * respond to hessian requests. The endpoint is closed by calling the destroy 
 * method./*from ww w.  j  a v  a2  s .  com*/
 */
public void run() {
    logger.debug("Launching endpoint for service : " + serviceAPI.getSimpleName());
    admin = new RabbitAdmin(connectionFactory);
    // Add connectionListener to recreate queue when connection fall
    connectionFactory.addConnectionListener(new ConnectionListener() {
        public void onCreate(Connection connection) {
            createQueue(admin, getRequestQueueName(serviceAPI));
        }

        public void onClose(Connection connection) {
        }

    });

    // Create the queue normaly the first time
    this.createQueue(admin, getRequestQueueName(serviceAPI));

    MessageListenerAdapter listenerAdapter = new MessageListenerAdapter(
            new RawMessageDelegate(serviceAPI, serviceImpl, serializerFactory));
    listenerAdapter.setMessageConverter(null);
    listenerAdapter.setMandatoryPublish(false);

    listenerContainer = new SimpleMessageListenerContainer();
    listenerContainer.setConnectionFactory(connectionFactory);
    listenerContainer.setQueueNames(getRequestQueueName(serviceAPI));
    listenerContainer.setMessageListener(listenerAdapter);
    if (this.concurentConsumers > 0) {
        listenerContainer.setConcurrentConsumers(concurentConsumers);
    }
    listenerContainer.start();
}