redmq


License

License

GroupId

GroupId

com.github.thisxulz
ArtifactId

ArtifactId

redmq
Last Version

Last Version

0.0.7
Release Date

Release Date

Type

Type

pom
Description

Description

redmq
redmq
Project URL

Project URL

https://github.com/thisxulz/RedMQ
Source Code Management

Source Code Management

https://github.com/thisxulz/RedMQ

Download redmq

Filename Size
redmq-0.0.7.pom 4 KB
Browse

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • redmq-web
  • redmq-client
  • redmq-utils

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