1. 程式人生 > 其它 >Java筆記-Spring-rabbitmq中設定receiveMessage引數為Message

Java筆記-Spring-rabbitmq中設定receiveMessage引數為Message

技術標籤:JavaRabbitMQSpring Bootjavaspring bootspring rabbitmq

如下程式碼:

public void receiveMessage(Message message){
	......
    ......
}

其中對應的Message為此包:

import org.springframework.amqp.core.Message;

在listner中這樣設定就可以了:

    MessageListenerAdapter listenerAdapter(Receiver receiver){

        MessageListenerAdapter receiveMessage = new MessageListenerAdapter(receiver, "receiveMessage");
        receiveMessage.setMessageConverter(null);
        return receiveMessage;
    }

關鍵程式碼是將MessageConverter設定為null,即可。