基於Redis
實現的分布式消息順序消費管道。
GitHub地址:https://github.com/minbox-projects/message-pipe
Gitee地址:https://gitee.com/minbox-projects/message-pipe
Message Pipe
是基於Redis
實現的順序消息管道,由於內部引入了Redisson
分布式鎖所以它是線程安全的,多線程情況下也會按照寫入管道的順序執行消費。
Message Pipe
採用Client
、Server
概念進行設計,內部通過grpc-netty
來建立消息通道相互通信的長連接,消息的分發由Server
負責,而每一個管道內的消息在分發時會通過LoadBalance(負載均衡)
的方式來獲取在線的Client
信息並向Client
順序發送消息。
為了快速上手,提供了message-pipe
使用的示例項目,項目源碼:https://github.com/minbox-projects/message-pipe-example。
由於message-pipe
基於Redis
實現,所以我們首先需要在本機安裝Redis
,下面是使用Docker
方式安裝步驟:
# 拉取Redis鏡像docker pull redis# 創建一個名為"redis"的後臺運行容器,埠號映射宿主機6379docker run --name redis -d -p 6379:6379 redis
# 運行容器內命令docker exec -it redis /bin/sh# 運行Redis客戶端redis-cli# 選擇索引為1的資料庫select 1# 查看全部的數據keys *
# 下載源碼git clone https://github.com/minbox-projects/message-pipe-example.git# 進入項目目錄cd message-pipe-example# 運行項目mvn spring-boot:run
message-pipe
採用Apache2開源許可進行編寫。