Skip to content

Extension of Quarkus example with structured content mode #465

@sjaakd

Description

@sjaakd

I like the Quarkus example.

However, it seems to use the Binary Content Mode. I however require the Structured Content Mode. Initially I did not even notice that the binary mode left out the metadata from the body. I did not even notice initially there were 2 modes.

It took me quite some time that all that's required is adding the annotation @Consumes( JsonFormat.CONTENT_TYPE ) to the client:

@Path( "/notify" )
@RegisterRestClient
public interface BrokerClient {

    @POST
    @Consumes( JsonFormat.CONTENT_TYPE )
    void emit( CloudEvent event);
}

Will trigger sending the request in the Structured Content Mode.

Likewise adding a @Consumes( JsonFormat.CONTENT_TYPE ) to the server:

    @POST
    @Path( "notify" )
    @Consumes( JsonFormat.CONTENT_TYPE )
    public Response create( CloudEvent event ) {
         // logic
    }

Fixes the server part. All the more confusing is that this reference mentions the Quarkus example (while discussing the structured content mode).

Suggestion: update the README.md or extend the example.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions