Much harder with V2 than V1 to send binary CloudEvents
See original GitHub issueI might be missing something, but it seems to me that it has become much harder to send binary CloudEvents with the V2 SDK, unless you happen to be using one of the small number of supported HTTP clients. In V1, I could write this:
Wire<String, String, String> wire = Marshallers.<Map<String, Object>>binary()
.withEvent(() -> myCloudEvent)
.marshal();
Then I basically just needed to copy wire.getHeaders()
into the HTTP headers of the request and have wire.getPayload().get()
be the HTTP body. That’s easy to do with pretty much any HTTP API.
With V2 it looks like I am out of luck if there isn’t already a MessageWriter
defined for the specific HTTP API that I am using. It’s not that hard to make a MessageWriter
by following the example of one of the existing ones, but it’s still about 50 lines of non-trivial code.
Could we have the simplicity of V1 back? Perhaps with a trivial MessageWriter implementation that just stashes the HTTP headers in a Map<String, String>
and the body in a byte[]
or whatever, which is more or less what the old Wire
did. It’s nice that the supported HTTP clients are so easy to use, but it seems to be at the cost of making anything else much harder.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top GitHub Comments
@eamonnmcmanus I tried to create generic http binding https://github.com/cloudevents/sdk-java/pull/225, please look at it.
It the PR #225 I added generic Message(Reader|Writer) and factory methods to instantiate them + some convenience static methods: