Skip to content

haifengChang84/rabbitmq-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rabbitmq-client base spring-rabbit and spring-amqp

基于spring-amqp的rabbitmq客户端

实现rabbitmq的监听消费和发送消息功能

构建安装

使用maven构建

  • 下载安装rabbitmq-client
git clone https://github.com/hashio/websocket-client.git
cd rabbitmq-client
mvn clean install
  • 在你的应用中添加rabbitmq-client 依赖到pom.xml
<dependency>
  <groupId>me.poplaris</groupId>
  <artifactId>rabbitmq-client</artifactId>
  <version>1.0</version>
</dependency>

用法

  • 实现消息监听消费
class ApiProcessEventProcessor implements EventProcesser{
    @Override
    public void process(Object e) {//消费程序这里只是打印信息
        System.out.println(e);
    }
}
  • 启动控制器
String defaultHost = "127.0.0.1";
String defaultExchange = "EXCHANGE_DIRECT_TEST";
String defaultQueue = "QUEUE_TEST";
EventControlConfig config = new EventControlConfig(defaultHost);
DefaultEventController controller = DefaultEventController.getInstance(config);
EventTemplate eventTemplate = controller.getEopEventTemplate();
controller.add(defaultQueue, defaultExchange, new ApiProcessEventProcessor());
controller.start();
  • 发送字符串消息
eventTemplate.send(defaultQueue, defaultExchange, "hello world");
  • 发送序列化对象消息
eventTemplate.send(defaultQueue, defaultExchange, mockObj());

参见博客

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%