测试demo 来自官方例子

使用docker-compose 进行运行

nats docker-compose file

version: '3.3'
services:
nats:
image: nats
ports:
- "4222:4222"
- "8222:8222"
- "6222:6222"

benthos stream 配置

参考 https://github.com/Jeffail/benthos/tree/master/resources/docker/streams

  • 整体说明
    里面的例子就是数据从文件读取到nats 之后不同的消费者进行nats 消息消费,再到webhook,webhook 标准输出

  • 文件读取说明

    读取文件,之后到nats

input:
type: read_until
read_until:
condition:
type: static
static: false
input:
type: file
file:
path: ./sample.json
restart_input: true
pipeline:
processors:
- type: throttle
throttle:
period: 3s
output:
type: nats
nats:
subject: benthos_messages
urls:
- nats://localhost:4222
  • nats 消费者(三个)
input:
type: nats
nats:
subject: benthos_messages
urls:
- nats://localhost:4222
pipeline:
processors:
- type: filter
filter:
type: jmespath
jmespath:
query: |
keys(@) | contains(@, 'title')
output:
type: http_client
http_client:
url: http://localhost:4195/webhooks/post/customer1
verb: POST
  • webhook 配置
input:
type: broker
broker:
inputs:
- type: http_server
http_server:
path: /post/customer1
processors:
- type: text
text:
operator: prepend
value: "Customer 1 received: "
- type: http_server
http_server:
path: /post/customer2
processors:
- type: text
text:
operator: prepend
value: "Customer 2 received: "
- type: http_server
http_server:
path: /post/customer3
processors:
- type: text
text:
operator: prepend
value: "Customer 3 received: "
output:
type: stdout

运行

  • docker-compose
dokcer-compose up -d
  • 启动benthos,基于文件stream 配置
benthos --streams --streams-dir ./configs

运行效果


修改sample.json 测试

参考资料

https://github.com/Jeffail/benthos/tree/master/resources/docker/streams

 
 
 
 

最新文章

  1. 也谈谈AlphaGo
  2. django xadmin 插件(1)
  3. 2016-06-08:Windows中的bat脚本
  4. BZOJ2494 Triangles and Quadrangle
  5. 关于Apache Struts 2 S2-032高危漏洞的一些确认
  6. 本地plsqldev.exe连接远端oracle数据库
  7. 强悍的 CSS 扩展语言 -- Sass
  8. 区别jquery对象和dom对象及转换方法
  9. 关于Videodownload helper的下载问题
  10. 用disabled属性修饰a标签,a标签仍然能点击
  11. PHP 多个构造函数
  12. PEP 8 python编程规范
  13. java框架之MyBatis(2)-进阶&整合Spring&逆向工程
  14. mongodb 批量修改
  15. shell执行字符串中的命令
  16. mysql 协议分析
  17. DVWA
  18. 一步一步学习IdentityServer4 (7) IdentityServer4成功配置全部配置
  19. L159
  20. 使用Boost库(1)

热门文章

  1. Sidekiq(部分基础,有几个使用案例和active_job的用法)
  2. qxx项目大文件上传
  3. hdu 1069 DAG加权
  4. xhost + 的作用
  5. @ConditionalOnProperty 详解
  6. 体验异步的终极解决方案-ES7的Async/Await
  7. spring cloud图形化dashboard是如何实现指标的收集展示的
  8. Python的数据类型1数值和字符串
  9. learning shell built-in variables (1)
  10. ZOJ 3829 Known Notation 贪心 难度:0