mistyzyq opened a new issue, #2444: URL: https://github.com/apache/incubator-eventmesh/issues/2444
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues. ### Environment Windows ### EventMesh version master ### What happened I have tried the http.demo project in the eventmesh-examples module, the _SyncRequestInstance_ does not work currently. by reading and many debugging work, I found out that, when getProtocolAdaptor(), the protocol type is hardcoded as "cloudevents" in method processRequest() of _Send**Sync**MessageProcessor_ class: ``` ProtocolAdaptor<ProtocolTransportObject> httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor("cloudevents"); CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); ``` In SyncRequestInstance, this object of asyncContext.getRequest() is instance of EventMeshMessage, so an exception is thrown when convert it to CloudEvent. Another example in http.demo, the _AsyncPublishInstance_ works fine, which bind the _Send**Async**MessageProcessor_. In the async processor, the same code block is like this: ``` SendMessageRequestHeader sendMessageRequestHeader = (SendMessageRequestHeader) asyncContext.getRequest().getHeader(); SendMessageResponseHeader sendMessageResponseHeader = SendMessageResponseHeader.buildHeader(Integer.valueOf(asyncContext.getRequest().getRequestCode()), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshCluster, IPUtils.getLocalAddress(), eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshEnv, eventMeshHTTPServer.getEventMeshHttpConfiguration().eventMeshIDC); String protocolType = sendMessageRequestHeader.getProtocolType(); String protocolVersin = sendMessageRequestHeader.getProtocolVersion(); ProtocolAdaptor<ProtocolTransportObject> httpCommandProtocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType); CloudEvent event = httpCommandProtocolAdaptor.toCloudEvent(asyncContext.getRequest()); ``` Should the hard-coded protocol type here be changed to dynamic fetching like this? ``` SendMessageRequestHeader sendMessageRequestHeader = (SendMessageRequestHeader) asyncContext.getRequest().getHeader(); ``` ### How to reproduce 1. startup the eventmesh-runtime; 2. start the SyncRequestInstance; 3. An exception will be thrown: io.cloudevents.core.format.EventDeserializationException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'contentStr': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (byte[])"contentStr with special protocal"; line: 1, column: 12] ### Debug logs output in the console: > Task :eventmesh-starter:StartUp.main() 00:54:42.117 [eventMesh-sendMsg-] ERROR org.apache.eventmesh.runtime.boot.EventMeshHTTPServer - process error org.apache.eventmesh.protocol.api.exception.ProtocolHandleException: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'contentStr': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (byte[])"contentStr with special protocal"; line: 1, column: 12] at org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageRequestProtocolResolver.buildEvent(SendMessageRequestProtocolResolver.java:105) ~[eventmesh-protocol-cloudevents-1.3.0-release.jar:1.3.0-release] at org.apache.eventmesh.protocol.cloudevents.CloudEventsProtocolAdaptor.deserializeHttpProtocol(CloudEventsProtocolAdaptor.java:98) ~[eventmesh-protocol-cloudevents-1.3.0-release.jar:1.3.0-release] at org.apache.eventmesh.protocol.cloudevents.CloudEventsProtocolAdaptor.toCloudEvent(CloudEventsProtocolAdaptor.java:76) ~[eventmesh-protocol-cloudevents-1.3.0-release.jar:1.3.0-release] at org.apache.eventmesh.runtime.core.protocol.http.processor.SendSyncMessageProcessor.processRequest(SendSyncMessageProcessor.java:94) ~[eventmesh-runtime-1.3.0-release.jar:1.3.0-release] at org.apache.eventmesh.runtime.boot.AbstractHTTPServer$HTTPHandler.lambda$processEventMeshRequest$1(AbstractHTTPServer.java:501) ~[eventmesh-runtime-1.3.0-release.jar:1.3.0-release] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_202] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_202] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_202] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_202] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202] Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'contentStr': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (byte[])"contentStr with special protocal"; line: 1, column: 12] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:745) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidToken(UTF8StreamJsonParser.java:3634) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2734) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:902) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:794) ~[jackson-core-2.13.0.jar:2.13.0] at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4762) ~[jackson-databind-2.13.0.jar:2.13.0] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4668) ~[jackson-databind-2.13.0.jar:2.13.0] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3691) ~[jackson-databind-2.13.0.jar:2.13.0] at io.cloudevents.jackson.JsonFormat.deserialize(JsonFormat.java:99) ~[cloudevents-json-jackson-2.2.0.jar:?] at org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageRequestProtocolResolver.buildEvent(SendMessageRequestProtocolResolver.java:66) ~[eventmesh-protocol-cloudevents-1.3.0-release.jar:1.3.0-release] ... 9 more ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
