Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DefaultMessage #146

Closed
bitzl opened this issue Apr 2, 2020 · 1 comment
Closed

Remove DefaultMessage #146

bitzl opened this issue Apr 2, 2020 · 1 comment
Labels
breaking Marks a breaking change
Milestone

Comments

@bitzl
Copy link
Member

bitzl commented Apr 2, 2020

Problem

Flusswerk encourages implementation of custom messages that fit the respective applications. For a quick start, a DefaultMessage class is provided that has an String id and da Map<String, String> data.

This approach has several drawbacks:

Overuse of DefaultMessage in applications

There have are many applications where Developers use the HashMap<String, String> of DefaultMessage instead of a custom implementation, not only losing type safety and type information, but also revert to frequent String parsing and String comparison.

A custom message implementation also has a simpler JSON structure which greatly improves debugging and testing .

Mistaken use inside the Framework

The existence of DefaultMessage can be misleading on the Framework development itself, as to the confusing error handling implementation when receiving a message fails where a DefaultMessage is constructed, mimicking a broken message of arbitrary type:

} catch (Exception e) {
Message invalidMessage = new DefaultMessage();
invalidMessage.getEnvelope().setBody(body);
invalidMessage.getEnvelope().setDeliveryTag(response.getEnvelope().getDeliveryTag());
invalidMessage.getEnvelope().setSource(queueName);
throw new InvalidMessageException(invalidMessage, e.getMessage());

Solution

Remove DefaultMessage and require a custom message implementation. Almost all usage is only in examples and tests where a suitable implementation can be provided. For easy implementation of custom messages, the abstract FlusswerkMessage can be used (also TraceableMessage, see #147).

@bitzl bitzl changed the title DefaultMessage Remove DefaultMessage Apr 3, 2020
@bitzl bitzl added this to the Flusswerk 4.0 milestone Apr 3, 2020
@bitzl bitzl added the breaking Marks a breaking change label Apr 3, 2020
@bitzl
Copy link
Member Author

bitzl commented May 8, 2020

Resolved by #165

@bitzl bitzl closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Marks a breaking change
Projects
None yet
Development

No branches or pull requests

1 participant