Skip to content

Commit

Permalink
[ISSUE apache#4623]Fix cloudEvents variable names do not support unde…
Browse files Browse the repository at this point in the history
…rscores
  • Loading branch information
mxsm committed Dec 7, 2023
1 parent 8c59c7f commit af2ec20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class ProtocolKey {

public static final String CLIENT_TYPE = "clienttype";

public static final String GRPC_RESPONSE_CODE = "status_code";
public static final String GRPC_RESPONSE_MESSAGE = "response_message";
public static final String GRPC_RESPONSE_CODE = "statuscode";
public static final String GRPC_RESPONSE_MESSAGE = "responsemessage";
public static final String GRPC_RESPONSE_TIME = "time";

public static final String SUB_MESSAGE_TYPE = "submessagetype";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.util.List;
import java.util.Objects;

import io.cloudevents.SpecVersion;

import com.fasterxml.jackson.core.type.TypeReference;
import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -163,7 +165,7 @@ public static boolean validateHeartBeat(CloudEvent heartbeat) {
public static void sendResponseCompleted(StatusCode code, String message, EventEmitter<CloudEvent> emitter) {

Instant instant = now();
CloudEvent.Builder builder = CloudEvent.newBuilder().setId(RandomStringUtils.generateUUID())
CloudEvent.Builder builder = CloudEvent.newBuilder().setId(RandomStringUtils.generateUUID()).setSpecVersion(SpecVersion.V1.toString())
.putAttributes(ProtocolKey.GRPC_RESPONSE_CODE, CloudEventAttributeValue.newBuilder().setCeString(code.getRetCode()).build())
.putAttributes(ProtocolKey.GRPC_RESPONSE_MESSAGE,
CloudEventAttributeValue.newBuilder().setCeString(code.getErrMsg() + EventMeshConstants.BLANK_SPACE + message).build())
Expand All @@ -182,7 +184,7 @@ public static void sendResponseCompleted(StatusCode code, String message, EventE
*/
public static void sendResponseCompleted(StatusCode code, EventEmitter<CloudEvent> emitter) {
Instant instant = now();
CloudEvent.Builder builder = CloudEvent.newBuilder()
CloudEvent.Builder builder = CloudEvent.newBuilder().setSpecVersion(SpecVersion.V1.toString())
.putAttributes(ProtocolKey.GRPC_RESPONSE_CODE, CloudEventAttributeValue.newBuilder().setCeString(code.getRetCode()).build())
.putAttributes(ProtocolKey.GRPC_RESPONSE_MESSAGE, CloudEventAttributeValue.newBuilder().setCeString(code.getErrMsg()).build())
.putAttributes(ProtocolKey.GRPC_RESPONSE_TIME, CloudEventAttributeValue.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.eventmesh.runtime.client.common.MessageUtils;
import org.apache.eventmesh.runtime.client.impl.SubClientImpl;


import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand Down

0 comments on commit af2ec20

Please sign in to comment.