Maven引入相关jar
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>3.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>

spring-mq.xml
<?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:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
<context:property-placeholder location="classpath:jdbc.properties,classpath:config.properties" />
<bean />
</rabbit:listener-container>

</beans>

生产者
public void thrwosmq(){
amqpTemplate.convertAndSend("jimmy-request-queue","ddd");
System.out.println("asdf");
}
消费者

public class Foo {  
public void handleRequestMessage(String aaa) {
System.out.println(aaa);
}

}




 

相关文章:

  • 2021-04-25
  • 2021-04-23
  • 2021-05-15
  • 2021-10-05
  • 2021-11-07
  • 2021-05-29
  • 2021-07-30
  • 2021-08-24
猜你喜欢
  • 2021-12-20
  • 2022-12-23
  • 2021-07-23
  • 2021-08-18
  • 2021-07-01
  • 2021-06-05
  • 2021-07-21
相关资源
相似解决方案