Skip to content

Much harder with V2 than V1 to send binary CloudEvents #212

@eamonnmcmanus

Description

@eamonnmcmanus

I 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions