hermes 是一个不错的基于kafaka 的event broker,基于push模型(webhook)
测试环境使用docker-compose 运行

环境准备

  • docker-compose
 
version: '3'
services:
  graphite:
    image: nickstenning/graphite
    ports:
      - "80:80"
      - "2003:2003"
  frontend:
    image: allegro/hermes-frontend
    ports:
      - "8080:8080"
    depends_on:
      - zk
      - kafka
      - graphite
  zk:
    image: wurstmeister/zookeeper:3.4.6
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka:1.1.0
    ports:
      - "9092:9092"
    depends_on:
      - zk
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zk:2181
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
      KAFKA_DELETE_TOPIC_ENABLE: 'true'
      KAFKA_BROKER_ID: 0
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  consumers:
    image: allegro/hermes-consumers
    depends_on:
      - zk
      - kafka
      - graphite
  benthos:
    image: jeffail/benthos
    volumes:
    - "./conf/webhook.yaml:/benthos.yaml"
    ports:
    - "4195:4195"
  management:
    image: allegro/hermes-management
    ports:
      - "8090:8090"
    depends_on:
      - zk
      - kafka
      - graphite
 
 
  • 运行
docker-compose up -d
 
  • webhook 服务
    webhook 服务使用benthos,配置如下
 
input:
  type: broker
  broker:
    inputs:
      - type: http_server
        http_server:
          path: /
        processors:
          - type: text
            text:
              operator: prepend
              value: "get message: "
output:
  type: stdout
 
 
  • 参考架构图
  • 组件说明
    frontend 进行消息发送
    consumers 消息订阅
    manger 管理主题以及订阅
    message store 存储以及路由消息当前支持的是kafka
    medata store 共享状态,当前使用的是zk
    metrics store 可选的,存储metrics 信息,当前是graphite
    tracking store 存储追踪信息,当前是es

测试

  • 创建group && topic
    注意应该使用management 的rest api 地址,对应docker 环境为8090 端口,注意topic的格式
    应该为 groupname.topicname
 
group: 
curl -X POST -H "Content-Type: application/json" http://localhost:8090/groups -d '{"groupName": "dalong"}'
topic:
curl -X POST -H "Content-Type: application/json" http://localhost:8090/topics -d '{
    "name": "dalong.userlogin",
    "description": "This is userlogin topic",
    "contentType": "JSON",
    "retentionTime": {
        "duration": 1
    },
    "owner": {
        "source": "Plaintext",
        "id": "dalong"
    }
}'
 
  • 创建订阅
    注意应该使用management 的rest api 地址,对应docker 环境为8090 端口,注意topic的格式
    应该为 groupname.topicname
 
curl -X POST -H "Content-Type: application/json" http://localhost:8090/topics/dalong.userlogin/subscriptions -d '{
    "topicName": "dalong.userlogin",
    "name": "userlogin", 
    "description": "This is my subscription",
    "endpoint": "http://benthos:4195/", 
    "owner": {
        "source": "Plaintext",
        "id": "dalong"
    }
}'
 
 
http://localhost:8090/topics/dalong.userlogin/subscriptions/userlogin/state
 

应该为:ACTIVE
支持的状态有:SUSPENDED,ACTIVE

  • 发送
 
curl -X POST -H "Content-Type: application/json" http://localhost:8080/topics/dalong.userlogin -d '{"message": "Hello world!"}'
 
  • 查看发送消息状态
docker-compose logs -f frontend benthos
 

效果

Attaching to hermes-project_frontend_1, hermes-project_benthos_1
benthos_1 | {"@timestamp":"2018-12-16T03:28:15Z","@service":"benthos","level":"INFO","component":"benthos","message":"Launching a benthos instance, use CTRL+C to close."}
benthos_1 | {"@timestamp":"2018-12-16T03:28:15Z","@service":"benthos","level":"INFO","component":"benthos","message":"Listening for HTTP requests at: http://0.0.0.0:4195\n"}
benthos_1 | get message: {"message": "Hello world!"}
 

说明

hermes 使用起来还是比较方便的,但是官方的docker-compose 对于kafaka 的配置有点问题

参考资料

https://hermes-pubsub.readthedocs.io/en/latest/
https://github.com/rongfengliang/hermes-docker-compose

hermes 试用的更多相关文章

  1. SharePoint Online 申请试用链接地址

    SharePoint Online 申请试用链接地址: https://products.office.com/en-us/business/compare-office-365-for-busine ...

  2. 活动助手Beta用户试用报告

    用户试用报告 1.面向参与者用户 1.1 日常参加各类学习(水综测)活动中,有没有遇到以下问题: (1) 信息来源混乱,不知道靠不靠谱 (2) 每次报名都要重新填写自己的学号手机号,有时候填错了就没综 ...

  3. 创建WP8试用应用

    参考资料: 创建 Windows Phone 的试用应用 如何在 Windows Phone 应用中实现试用体验 Windows Phone 7 开发 31 日谈——第23日:提供试用版应用程序 对资 ...

  4. 达梦7的试用 与SQLSERVER的简单技术对比

    达梦7的试用 与SQLSERVER的简单技术对比 达梦数据库公司推出了他们的数据库服务管理平台,可以在该平台使用达梦数据库而无须安装达梦7数据库 地址:http://online.dameng.com ...

  5. Beta版本——用户试用与调研报告

    1 引言 1.1 系统概述 ​ 毕设导师智能分配系统是一个用来简化传统手工匹配繁琐操作的系统.本系统将学生报志愿.系负责人收集整理数据.相关人员进行手工分配.反馈选择结果等繁琐的操作转移到线上.把毕设 ...

  6. 【记录】尝试用android-logging-log4j去实现log输出内容到sd卡中的文件的功能

    [背景] 折腾: [记录]给Android中添加log日志输出到文件 期间,已经试了: [记录]尝试用android中microlog4android实现log输出到文件的功能 但是不好用. 然后就是 ...

  7. 代码阅读分析工具Understand 2.0试用

    Understand 2.0是一款源代码阅读分析软件,功能强大.试用过一段时间后,感觉相当不错,确实可以大大提高代码阅读效率.由于Understand功能十分强大,本文不可能详尽地介绍它的所有功能,所 ...

  8. 如何申请国际版Office365和Azure的试用账号

    关键字:国际版.Office365.Azure.试用账号.1美元.信用卡 待续

  9. Android N preview 试用

    一.下载更新包 下载地址:https://developer.android.com/intl/zh-cn/preview/download.html 注意下载适合你手机的安装包哦 二.把你手机的oe ...

随机推荐

  1. TypeError: write() argument must be str, not bytes报错原因及Python3写入二进制文件方法

    Python2随机写入二进制文件: with open('/python2/random.bin','w') as f: f.write(os.urandom(10)) 但使用Python3会报错: ...

  2. JavaScript+CSS+DIV实现表格变色示例

    <!DOCTYPE html> <html> <head> <title>colortable.html</title> <scrip ...

  3. linux 常用重启

    sudo reboot 为最常用重启 Linux centos关机与重启命令详解与实战 Linux centos重启命令: 1.reboot 普通重启 2.shutdown -r now 立刻重启(r ...

  4. springboot学习章节代码-Spring MVC基础

    1.项目搭建. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt ...

  5. L293 给地球降温

    Countries look at ways to tinker with Earth’s thermostat The idea of cooling the climate with strato ...

  6. nginx随机模块——ngx_http_random_index_module

    今天我给大家分享一个挺好玩的模块,随机变换网站首页的模块 这个模块他的作用于只有在location中,具体写法如下 只需要在localtion开启这个模块就好了,然后呢我们在/usr/share/ng ...

  7. DeployMan,发布文件的利器

    利用Delphi开发app,有时候需要发布文件,如果文件少还不是问题,但文件多的情况下,IDE带的发布功能,就显得捉襟见肘,效率低下了. 通过Project-Deployment,打开发布窗口,如下图 ...

  8. Linux命令--1

    之前一直在学习Linux,不过有点一天打鱼两天晒网的意味,现在希望通过写博客的形式,积累更多的知识,也希望可以帮到同在linux坑中的各位小伙伴们~ PS:我的笔记重点在于通俗,很多命令一百度就有,但 ...

  9. ANDROID BINDER机制浅析

    Binder是Android上一种IPC机制,重要且较难理解.由于Linux上标准IPC在灵活和可靠性存在一定不足,Google基于OpenBinder的设计和构想实现了Binder. 本文只简单介绍 ...

  10. web.net用户控件

    1.它是以 Control注册 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind=& ...