Skip to content

Commit

Permalink
0005006: Push, pull, extract thread name has wrong queue
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed May 27, 2021
1 parent d87f547 commit cfa7daf
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ public void run() {
boolean failed = false;
try {
MDC.put("engineName", parameterService.getEngineName());
String name = parameterService.getEngineName().toLowerCase() + "-" + nodeCommunication.getCommunicationType().name().toLowerCase() +
"-" + nodeCommunication.getQueue().toLowerCase();
Thread thread = Thread.currentThread();
thread.setName(thread.getName().replaceFirst(".*(-\\d+)", name + "$1"));

executor.execute(nodeCommunication, status);
failed = status.failed();
} catch (Throwable ex) {
Expand All @@ -551,7 +556,6 @@ public void run() {
} else {
ThreadPoolExecutor service = getExecutor(nodeCommunication.getCommunicationType(),
nodeCommunication.getQueue());
((ChannelThreadFactory) service.getThreadFactory()).setChannelThread(nodeCommunication.getQueue());
service.execute(r);
}
}
Expand Down Expand Up @@ -666,24 +670,14 @@ static class ChannelThreadFactory implements ThreadFactory {
private final AtomicInteger threadNumber = new AtomicInteger(1);
private String engineName;
private String communicationType;
private String channelThread;

public ChannelThreadFactory(String engineName, String communicationType) {
this.engineName = engineName;
this.communicationType = communicationType;
}

String getChannelThread() {
return channelThread != null ? this.channelThread : "default";
}

void setChannelThread(String channelThread) {
this.channelThread = channelThread;
}

public String getThreadPrefix() {
return new StringBuffer(engineName.toLowerCase()).append("-").append(communicationType.toLowerCase()).append("-")
.append(getChannelThread()).append("-").toString();
return new StringBuffer(engineName.toLowerCase()).append("-").append(communicationType.toLowerCase()).append("-default-").toString();
}

public Thread newThread(Runnable r) {
Expand Down

0 comments on commit cfa7daf

Please sign in to comment.