.
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user