Code Monkey home page Code Monkey logo

rabbitmq-client's Introduction

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());

参见博客

rabbitmq-client's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.