1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<rabbit:connection-factory id="connectionFactory" host="localhost" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="myQueue" />
<rabbit:topic-exchange name="myExchange"> <rabbit:bindings> <rabbit:binding queue="myQueue" pattern="fooz.*" /> </rabbit:bindings> </rabbit:topic-exchange>
<rabbit:template id="rabbitTemplate" connection-factory="connectionFactory" exchange="myExchange" routing-key="foo.bar" />
<rabbit:listener-container connection-factory="connectionFactory"> <rabbit:listener ref="consumer" method="listen" queue-names="myQueue" /> </rabbit:listener-container>
<bean id="consumer" class="com.mushan.rabbit.spring.Consumer" /> </beans>
|