.
This commit is contained in:
parent
17b28a9124
commit
23365ae237
@ -21,6 +21,9 @@ public interface IConsumer<T extends Event> {
|
|||||||
String _value = value.split("\"value\":")[1];
|
String _value = value.split("\"value\":")[1];
|
||||||
_value = _value.substring(0, _value.length() - 1);
|
_value = _value.substring(0, _value.length() - 1);
|
||||||
Event t = JsonConvert.root().convertFrom(getTypeToken().getType(), value.replace(_value, "’‘"));
|
Event t = JsonConvert.root().convertFrom(getTypeToken().getType(), value.replace(_value, "’‘"));
|
||||||
|
if (_value.startsWith("\"") && _value.endsWith("\"")) {
|
||||||
|
_value = _value.substring(1, _value.length() -1);
|
||||||
|
}
|
||||||
t.setValue(_value);
|
t.setValue(_value);
|
||||||
accept((T) t);
|
accept((T) t);
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,6 +11,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Service {
|
public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Service {
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Se
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AnyValue config) {
|
public void init(AnyValue config) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
Socket client = new Socket();
|
Socket client = new Socket();
|
||||||
client.connect(new InetSocketAddress(host, port));
|
client.connect(new InetSocketAddress(host, port));
|
||||||
@ -70,5 +72,6 @@ public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Se
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@ public class AppTest {
|
|||||||
try {
|
try {
|
||||||
RedisProducer producer = Application.singleton(RedisProducer.class);
|
RedisProducer producer = Application.singleton(RedisProducer.class);
|
||||||
|
|
||||||
Event<Map> event = new Event<>();
|
Event event = new Event<>();
|
||||||
event.setTopic("c");
|
event.setTopic("c");
|
||||||
event.setKey("abx");
|
event.setKey("abx");
|
||||||
event.setValue(Map.of("A", "a"));
|
event.setValue(1f);
|
||||||
|
|
||||||
producer.send(event);
|
producer.send(event);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user