V0.5.x
荭琪枫 2023-05-08 18:29:42 +08:00
parent fbe2565119
commit f6e3c46276
14 changed files with 204 additions and 1 deletions

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iot-message-bus</artifactId>
<groupId>cc.iotkit</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iot-message-notify</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-model</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-message-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,11 @@
### 支持rocketMq作为消息总线
版本0.4.2
rocketMq版本4.9.4
####开启方式:
1、application.yml中打开注释支持rocketMq作为消息总线
2、pom.xml中打开注释使用rocketmq消息总线

View File

@ -0,0 +1,9 @@
package cc.iotkit.message.model;
/**
* author:
* date: 2023-05-08 15:58
* description:
**/
public class DingTalkMessage extends Message{
}

View File

@ -0,0 +1,9 @@
package cc.iotkit.message.model;
/**
* author:
* date: 2023-05-08 15:58
* description:
**/
public class EmailMessage extends Message {
}

View File

@ -0,0 +1,10 @@
package cc.iotkit.message.model;
/**
* author:
* date: 2023-05-08 15:15
* description:
**/
public abstract class Message {
private String content;
}

View File

@ -0,0 +1,9 @@
package cc.iotkit.message.model;
/**
* author:
* date: 2023-05-08 15:58
* description:
**/
public class QyWechatMessage extends Message{
}

View File

@ -0,0 +1,16 @@
package cc.iotkit.message.notify;
import cc.iotkit.message.model.Message;
/**
* author:
* date: 2023-05-08 15:09
* description:
**/
public class DingTalkEventListener implements EventListener{
@Override
public void doEvent(Message message) {
}
}

View File

@ -0,0 +1,12 @@
package cc.iotkit.message.notify;
import cc.iotkit.message.model.Message;
/**
* author:
* date: 2023-05-08 15:08
* description:
**/
public interface EventListener {
void doEvent(Message message);
}

View File

@ -0,0 +1,35 @@
package cc.iotkit.message.notify;
import cc.iotkit.message.model.Message;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* author:
* date: 2023-05-08 15:17
* description:
**/
public class EventManager {
Map<Enum<EventType>, List<EventListener>> listeners = new HashMap<>();
public void subscribe(Enum<EventType> eventType, EventListener listener) {
List<EventListener> users = listeners.get(eventType);
users.add(listener);
}
public void unsubscribe(Enum<EventType> eventType, EventListener listener) {
List<EventListener> users = listeners.get(eventType);
users.remove(listener);
}
public void notify(Enum<EventType> eventType, Message result) {
List<EventListener> users = listeners.get(eventType);
for (EventListener listener : users) {
listener.doEvent(result);
}
}
}

View File

@ -0,0 +1,10 @@
package cc.iotkit.message.notify;
/**
* author:
* date: 2023-05-08 15:21
* description:
**/
public enum EventType {
MQ, Message
}

View File

@ -0,0 +1,16 @@
package cc.iotkit.message.notify;
import cc.iotkit.message.model.Message;
/**
* author:
* date: 2023-05-08 15:09
* description:
**/
public class MessageEventListener implements EventListener{
@Override
public void doEvent(Message message) {
}
}

View File

@ -0,0 +1,16 @@
package cc.iotkit.message.notify;
import cc.iotkit.message.model.Message;
/**
* author:
* date: 2023-05-08 15:09
* description:
**/
public class QyWechatEventListener implements EventListener{
@Override
public void doEvent(Message message) {
}
}

View File

@ -0,0 +1,16 @@
package cc.iotkit.message.service;
import cc.iotkit.message.notify.EventManager;
/**
* author:
* date: 2023-05-08 16:02
* description:
**/
public class MessageService {
public static void main(String[] args) {
EventManager em = new EventManager();
em.notify();
}
}

View File

@ -19,6 +19,7 @@
<module>iot-message-core</module>
<module>iot-vertx-event-bus</module>
<module>iot-message-rocketmq</module>
<module>iot-message-notify</module>
</modules>
<dependencies>
@ -44,4 +45,4 @@
</dependencies>
</project>
</project>