Skip to content

Commit

Permalink
perf(net-core): Enhance the invokeModuleMessage and invokeModuleColle…
Browse files Browse the repository at this point in the history
…ctMessage methods of the BrokerClientItem. The return value must not be null, and error information is added.
  • Loading branch information
iohao committed Dec 11, 2024
1 parent 7e80f1e commit 3ef7eb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ public BarMessage setError(MsgExceptionInfo msgExceptionInfo) {
public boolean hasError() {
return this.responseStatus != 0;
}

public boolean success() {
return !this.hasError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.iohao.game.action.skeleton.core.BarSkeleton;
import com.iohao.game.action.skeleton.core.SkeletonAttr;
import com.iohao.game.action.skeleton.core.commumication.CommunicationAggregationContext;
import com.iohao.game.action.skeleton.core.exception.ActionErrorEnum;
import com.iohao.game.action.skeleton.protocol.RequestMessage;
import com.iohao.game.action.skeleton.protocol.ResponseMessage;
import com.iohao.game.action.skeleton.protocol.collect.RequestCollectMessage;
Expand All @@ -53,8 +54,8 @@

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -161,18 +162,17 @@ public void broadcastOrder(ResponseMessage responseMessage) {

@Override
public ResponseMessage invokeModuleMessage(RequestMessage requestMessage) {

ResponseMessage o = null;

try {
InnerModuleMessage moduleMessage = new InnerModuleMessage();
moduleMessage.setRequestMessage(requestMessage);
o = (ResponseMessage) this.invokeSync(moduleMessage);
return (ResponseMessage) this.invokeSync(moduleMessage);
} catch (RemotingException | InterruptedException e) {
log.error(e.getMessage(), e);
var responseMessage = requestMessage.createResponseMessage();
responseMessage.setResponseStatus(ActionErrorEnum.systemOtherErrCode.getCode());
responseMessage.setValidatorMsg(e.getMessage());
return responseMessage;
}

return o;
}

@Override
Expand All @@ -196,9 +196,13 @@ public ResponseCollectMessage invokeModuleCollectMessage(RequestMessage requestM
return (ResponseCollectMessage) this.invokeSync(requestCollectMessage);
} catch (RemotingException | InterruptedException e) {
log.error(e.getMessage(), e);
}
ResponseCollectMessage responseCollectMessage = new ResponseCollectMessage();
responseCollectMessage.setStatusCode(ActionErrorEnum.systemOtherErrCode.getCode());
responseCollectMessage.setStatusMes(e.getMessage());
responseCollectMessage.setMessageList(Collections.emptyList());

return null;
return responseCollectMessage;
}
}

@Override
Expand Down

0 comments on commit 3ef7eb3

Please sign in to comment.