You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "9997766 (via GitHub)" <gi...@apache.org> on 2024/04/01 07:53:37 UTC
[I] EventMeshMessageProducer exceptions swallowed problem (eventmesh)
9997766 opened a new issue, #4805:
URL: https://github.com/apache/eventmesh/issues/4805
### 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
Linux
### EventMesh version
1.10.0
### What happened
EventMeshMessageProducer.java have a problem, exceptions should not be swallowed.
This can cause serious business problems. When and in which version can you fix this issue?
@Override
public Response publish(List<EventMeshMessage> messages) {
if (CollectionUtils.isEmpty(messages)) {
return null;
}
CloudEventBatch cloudEventBatch = EventMeshCloudEventBuilder.buildEventMeshCloudEventBatch(messages, clientConfig, PROTOCOL_TYPE);
try {
CloudEvent response = publisherClient.batchPublish(cloudEventBatch);
Response parsedResponse = Response.builder()
.respCode(EventMeshCloudEventUtils.getResponseCode(response))
.respMsg(EventMeshCloudEventUtils.getResponseMessage(response))
.respTime(EventMeshCloudEventUtils.getResponseTime(response))
.build();
log.info("Received response:{}", parsedResponse);
return parsedResponse;
} catch (Exception e) {
log.error("Error in BatchPublish message {}", messages, e);
}
return null;
}
### How to reproduce
I suggest whether we can modify it as follow:
@Override
public Response publish(List<EventMeshMessage> messages) throw EventMeshException{
if (CollectionUtils.isEmpty(messages)) {
return null;
}
CloudEventBatch cloudEventBatch = EventMeshCloudEventBuilder.buildEventMeshCloudEventBatch(messages, clientConfig, PROTOCOL_TYPE);
try {
CloudEvent response = publisherClient.batchPublish(cloudEventBatch);
Response parsedResponse = Response.builder()
.respCode(EventMeshCloudEventUtils.getResponseCode(response))
.respMsg(EventMeshCloudEventUtils.getResponseMessage(response))
.respTime(EventMeshCloudEventUtils.getResponseTime(response))
.build();
log.info("Received response:{}", parsedResponse);
return parsedResponse;
} catch (Exception e) {
log.error("Error in BatchPublish message {}", messages, e);
throws new EventMeshException("Error in BatchPublish message {}", e );
}
return null;
}
### Debug logs
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *
--
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: issues-unsubscribe@eventmesh.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [I] EventMeshMessageProducer exceptions swallowed problem (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia closed issue #4805: EventMeshMessageProducer exceptions swallowed problem
URL: https://github.com/apache/eventmesh/issues/4805
--
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: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [I] EventMeshMessageProducer exceptions swallowed problem (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on issue #4805:
URL: https://github.com/apache/eventmesh/issues/4805#issuecomment-2029454308
The difference between the two pieces of code you provided is that the latter has a new `throws new EventMeshException` statement in the catch block.
In `eventmesh-sdk-java`, this exception is not handled by the caller of the `publish(EventMeshMessage message)` method. If the exception is rethrown, the user must catch this exception manually.
I think re-throwing exceptions is kind of a good idea to avoid situations where the user loses the message because they missed the ERROR level log.
--
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: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org