xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.6.xsd" >









    
        
        
    






监听类(消费者类)br/>@Component
public class Template1Listener implements ChannelAwareMessageListener {
private static final Logger log = LoggerFactory.getLogger(Template1Listener.class);br/>@Override
public void onMessage(Message message,Channel channel) {
System.out.println("监听到一个消息");
try {
//channel.basicAck(1L, false);
} catch (Exception e) {
e.printStackTrace();
}
}
}

生产者类(测试类)br/>@RunWith(SpringJUnit4Cla***unner.class)
@ContextConfiguration(locations = { "classpath:spring/*.xml" })
public class MessageTest {

@Autowired
private Template1Producer template1Producer;
@Test
public void m1() {
    while(true) {
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        template1Producer.send(new Date());
    }
}

}