|
@ -16,6 +16,7 @@ import org.zbus.net.http.Message;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.InetAddress;
|
|
import java.net.InetAddress;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -33,6 +34,7 @@ public class RemoteShellService {
|
|
private ServiceShellEventService serviceShellEventService;
|
|
private ServiceShellEventService serviceShellEventService;
|
|
private ZbusBroker zbusBroker;
|
|
private ZbusBroker zbusBroker;
|
|
private Consumer consumer;
|
|
private Consumer consumer;
|
|
|
|
private static Map<String,String> cunsumerNap = new HashMap<>();
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
@ -81,21 +83,11 @@ public class RemoteShellService {
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
if (consumer != null) {
|
|
|
|
//TODO new后,原对象引用可能断开无法找到;使用静态锁map来保存
|
|
|
|
consumer = new Consumer(zbusBroker, ServiceFlowConstant.SHELL_RESPONSE + "@" + attachment);
|
|
|
|
String messageBodyString = consumer.queryMQ().getBodyString();
|
|
|
|
Map<String,Object> message = objectMapper.readValue(messageBodyString,Map.class);
|
|
|
|
Integer consumerCount = (Integer) message.get("consumerCount");
|
|
|
|
|
|
|
|
if (consumerCount<1) {
|
|
|
|
consumer.start(this::handle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
if (!cunsumerNap.containsKey(ServiceFlowConstant.SHELL_RESPONSE + "@" + attachment)){
|
|
consumer = new Consumer(zbusBroker, ServiceFlowConstant.SHELL_RESPONSE + "@" + attachment);
|
|
consumer = new Consumer(zbusBroker, ServiceFlowConstant.SHELL_RESPONSE + "@" + attachment);
|
|
consumer.start(this::handle);
|
|
consumer.start(this::handle);
|
|
|
|
cunsumerNap.put(ServiceFlowConstant.SHELL_RESPONSE + "@" + attachment,attachment);
|
|
}
|
|
}
|
|
|
|
|
|
System.out.println("start success~");
|
|
System.out.println("start success~");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|