Java筆記-Spring-rabbitmq中設定receiveMessage引數為Message
阿新 • • 發佈:2020-12-25
技術標籤: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,即可。