有的应用场景中需要实现多个监听器,每个监听器监听不同的消息队列,实现不同的业务逻辑。下面分别介绍XML配置方式和Java配置方式。
一、XML配置方式
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/rabbit"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<connection-factory
id="connectionFactory"
host="localhost"