This commit is contained in:
lxy
2020-11-30 09:25:23 +08:00
parent 9138790fd2
commit 10472078b0
4 changed files with 26 additions and 37 deletions

View File

@@ -2,7 +2,9 @@ package com.zdemo;
import org.redkale.convert.json.JsonConvert;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @author Liang
@@ -32,11 +34,11 @@ public abstract class AbstractConsumer implements IConsumer {
@Override
public final Set<String> getTopics() {
Set<String> keySet = eventMap.keySet();
if (keySet.isEmpty()) {
keySet.add("-");
if (!eventMap.isEmpty()) {
return eventMap.keySet();
}
return keySet;
return Set.of("-");
}
@Override

View File

@@ -42,7 +42,11 @@ public class RedisProducer<T extends Event> implements IProducer<T>, Service {
@Override
public void send(T t) {
try {
osw.write("PUBLISH " + t.topic + " '" + JsonConvert.root().convertTo(t.value) + "' \r\n");
String v = JsonConvert.root().convertTo(t.value);
if (v.startsWith("\"") && v.endsWith("\"")) {
v = v.substring(1, v.length() - 1);
}
osw.write("PUBLISH " + t.topic + " '" + v + "' \r\n");
osw.flush();
} catch (IOException e) {
logger.log(Level.WARNING, "", e);