修改:kafka 订阅实现修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.zdemo.redis;
|
||||
|
||||
import com.zdemo.Event;
|
||||
import com.zdemo.AbstractConsumer;
|
||||
import com.zdemo.IConsumer;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.AnyValue;
|
||||
@@ -12,7 +12,7 @@ import java.io.OutputStreamWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Service {
|
||||
public abstract class RedisConsumer extends AbstractConsumer implements IConsumer, Service {
|
||||
|
||||
@Resource(name = "property.redis.host")
|
||||
private String host = "127.0.0.1";
|
||||
@@ -21,10 +21,6 @@ public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Se
|
||||
@Resource(name = "property.redis.port")
|
||||
private int port = 6379;
|
||||
|
||||
public String getGroupid() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(AnyValue config) {
|
||||
new Thread(() -> {
|
||||
@@ -61,9 +57,9 @@ public abstract class RedisConsumer<T extends Event> implements IConsumer<T>, Se
|
||||
br.readLine(); //$n len(value)
|
||||
String value = br.readLine(); // value
|
||||
try {
|
||||
accept(value);
|
||||
accept(topic, value);
|
||||
} catch (Exception e) {
|
||||
logger.warning("event accept error :" + value);
|
||||
logger.warning("topic[" + topic + "] event accept error :" + value);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ public class RedisProducer<T extends Event> implements IProducer<T>, Service {
|
||||
public void send(T... t) {
|
||||
for (T x : t) {
|
||||
try {
|
||||
oswPub.write("PUBLISH " + x.getTopic() + " '" + JsonConvert.root().convertTo(x) + "' \r\n");
|
||||
oswPub.write("PUBLISH " + x.topic + " '" + JsonConvert.root().convertTo(x.value) + "' \r\n");
|
||||
oswPub.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
Reference in New Issue
Block a user