redmq-client

redmq

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.thisxulz
ArtifactId

ArtifactId

redmq-client
Last Version

Last Version

0.0.7
Release Date

Release Date

Type

Type

jar
Description

Description

redmq-client
redmq
Project URL

Project URL

http://maven.apache.org

Download redmq-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.thisxulz/redmq-client/ -->
<dependency>
    <groupId>com.github.thisxulz</groupId>
    <artifactId>redmq-client</artifactId>
    <version>0.0.7</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.thisxulz/redmq-client/
implementation 'com.github.thisxulz:redmq-client:0.0.7'
// https://jarcasting.com/artifacts/com.github.thisxulz/redmq-client/
implementation ("com.github.thisxulz:redmq-client:0.0.7")
'com.github.thisxulz:redmq-client:jar:0.0.7'
<dependency org="com.github.thisxulz" name="redmq-client" rev="0.0.7">
  <artifact name="redmq-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.thisxulz', module='redmq-client', version='0.0.7')
)
libraryDependencies += "com.github.thisxulz" % "redmq-client" % "0.0.7"
[com.github.thisxulz/redmq-client "0.0.7"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.thisxulz : redmq-utils jar 0.0.5

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

RedMQ

基于redis的消息队列

maven配置:

<dependency>
	<groupId>com.github.thisxulz</groupId>
	<artifactId>redmq-client</artifactId>
	<version>0.0.7</version>
</dependency>

优点:

消息不丢失
消息不重复
分布式缓存锁
在线安全关闭消费队列(防消息丢失)
在线查看未处理消息数
在线查看消费线程数
在线注册topic和group
提供restfulAPI
实时监控/报警
兼容单机和集群

缺点:

重度依赖redis

Example

首先需要在线或者调用api注册topic和group,未注册的topic和group无法发送和接收消息 支持P2P,Publish/Subscribe

发送消息

String topicName = "testTopic";
//groupName为空时,消息发送给topic下注册的所有消费者分组,
//groupName不为空,消息只发送给对应的group分组
String groupName = "testGroup";
DefaultProducer defaultProducer = new DefaultProducer(topicName, groupName);
for(int i=0;i<100000;i++) {
  String message = "i am message " + i;
  defaultProducer.sendMessage(message);
}

处理消息

//同一个分组无法重复消息同一条消息,依赖redis的list实现
String topicName = "testTopic";
String groupName = "testGroup";
//可控制消费者线程数,默认单线程处理消息,可分布式部署多个节点处理消息
DefaultConsumer defaultConsumer = new DefaultConsumer(topicName, groupName, 2);
defaultConsumer.setMessageLinser(new MessageLinser() {
  @Override
  public MessageStatus consumeMessage(String message) {
    System.out.println(message);
    return MessageStatus.SUCCESS;
  }
});
defaultConsumer.start();

接口文档地址

http://localhost:8000/doc.html

在线管理地址

http://localhost:8000/msgs

在线管理 clone 代码到本地
修改 redmq-web 的配置文件 redmq.properties,配置redis单机或集群地址
根目录执行命令 mvn clean package
cd redmq-web
java -jar target/redmq-web.war
即可访问

查看消息队列,安全关闭消费者分组

在线查看、注册消息主题

在线查看、注册消费者分组

Versions

Version
0.0.7
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1