Files
redkale/src/org/redkale/mq/MessageAgent.java
Redkale 6c4a83d14d
2020-05-27 20:32:57 +08:00

58 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.mq;
import java.util.List;
import java.util.logging.Logger;
import org.redkale.util.AnyValue;
/**
* MQ管理
*
*
* 详情见: https://redkale.org
*
* @author zhangjx
*/
public abstract class MessageAgent {
protected String name;
protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
public void init(AnyValue config) {
}
public void destroy(AnyValue config) {
}
public String getName() {
return name;
}
protected String checkName(String name) { //不能含特殊字符
if (name.isEmpty()) throw new RuntimeException("name only 0-9 a-z A-Z _ cannot begin 0-9");
if (name.charAt(0) >= '0' && name.charAt(0) <= '9') throw new RuntimeException("name only 0-9 a-z A-Z _ cannot begin 0-9");
for (char ch : name.toCharArray()) {
if (!((ch >= '0' && ch <= '9') || ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { //不能含特殊字符
throw new RuntimeException("name only 0-9 a-z A-Z _ cannot begin 0-9");
}
}
return name;
}
//创建topic如果已存在则跳过
public abstract boolean createTopic(String... topics);
//删除topic如果不存在则跳过
public abstract boolean deleteTopic(String... topics);
//查询所有topic
public abstract List<String> queryTopic();
}