<!-- 以下为全部rabbitmq监听配置 -->
<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<property name="username" value="guest" />
<property name="password" value="guest" />
<property name="host" value="192.168.0.140" />
<property name="port" value="5672" />
</bean> -->
<!-- <bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<property name="username" value="admin" />
<property name="password" value="admin" />
<property name="host" value="127.0.0.1" />
<property name="port" value="5672" />
</bean> -->
<!-- <bean id="rabbitAdmin" class="org.springframework.amqp.rabbit.core.RabbitAdmin">
<constructor-arg ref="connectionFactory" />
</bean>
<bean id="serializerMessageConverter" class="org.springframework.amqp.support.converter.SimpleMessageConverter" />
创建rabbitTemplate 消息模板类
<bean id="rabbitTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate">
<constructor-arg ref="connectionFactory" />
<property name="exchange" value="SendAlarm_Exchange_forjava" />
<property name="routingKey" value="SendAlarm_Exchange_forjava" />
<property name="queue" value="weixin_queue" />
<property name="messageConverter" ref="serializerMessageConverter" />
</bean>
<bean id="queue" class="org.springframework.amqp.core.Queue">
<constructor-arg index="0" value="weixin_queue"></constructor-arg>
<constructor-arg index="1" value="true"></constructor-arg>
<constructor-arg index="2" value="false"></constructor-arg>
<constructor-arg index="3" value="false"></constructor-arg>
</bean>
<bean id="directExchange" class="org.springframework.amqp.core.DirectExchange">
<constructor-arg index="0" value="routingKey"></constructor-arg>
<constructor-arg index="1" value="true"></constructor-arg>
<constructor-arg index="2" value="false"></constructor-arg>
</bean>
<util:map id="arguments"></util:map>
<bean id="binding" class="org.springframework.amqp.core.Binding">
<constructor-arg index="0" value="weixin_queue"></constructor-arg>
<constructor-arg index="1" value="QUEUE"></constructor-arg>
<constructor-arg index="2" value="SendAlarm_Exchange_forjava"></constructor-arg>
<constructor-arg index="3" value="routingKey"></constructor-arg>
<constructor-arg index="4" value="#{arguments}"></constructor-arg>
</bean>
<bean id="rmqConsumer" class="com.yeexun.rabbit.RmqConsumer" />
<bean id="messageListenerAdapter" class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter">
<constructor-arg ref="rmqConsumer" />
<property name="defaultListenerMethod" value="rmqConsumeMessage"></property>
<property name="messageConverter" ref="serializerMessageConverter"></property>
</bean>
<bean id="listenerContainer" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
<property name="queues" ref="queue"></property>
<property name="connectionFactory" ref="connectionFactory"></property>
<property name="messageListener" ref="messageListenerAdapter"></property>
</bean>
weixin_queue标识队列名称
SendAlarm_Exchange_forjava标识exchange