diff --git a/quarkus/addons/common/reactive-messaging/src/main/java/org/kie/kogito/addon/quarkus/common/reactive/messaging/http/CloudEventHttpOutgoingDecorator.java b/quarkus/addons/common/reactive-messaging/src/main/java/org/kie/kogito/addon/quarkus/common/reactive/messaging/http/CloudEventHttpOutgoingDecorator.java index 2aed1745489..2e068729f4f 100644 --- a/quarkus/addons/common/reactive-messaging/src/main/java/org/kie/kogito/addon/quarkus/common/reactive/messaging/http/CloudEventHttpOutgoingDecorator.java +++ b/quarkus/addons/common/reactive-messaging/src/main/java/org/kie/kogito/addon/quarkus/common/reactive/messaging/http/CloudEventHttpOutgoingDecorator.java @@ -22,8 +22,10 @@ import org.kie.kogito.addon.quarkus.common.reactive.messaging.MessageDecorator; import io.quarkus.reactivemessaging.http.runtime.OutgoingHttpMetadata; +import io.smallrye.reactive.messaging.ce.OutgoingCloudEventMetadata; import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MediaType; /** * Decorators for Http CloudEvents outgoing messages @@ -40,6 +42,12 @@ public class CloudEventHttpOutgoingDecorator implements MessageDecorator { static final OutgoingHttpMetadata HTTP_RESPONSE_METADATA = new OutgoingHttpMetadata.Builder().addHeader(HttpHeaders.CONTENT_TYPE, CLOUD_EVENTS_CONTENT_TYPE).build(); + /** + * Metadata to include content-type for binary CloudEvents messages + */ + private static final OutgoingHttpMetadata HTTP_BINARY_RESPONSE_METADATA = + new OutgoingHttpMetadata.Builder().addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build(); + /** * Decorates a given payload with custom metadata needed by Http Outgoing processing * @@ -48,6 +56,6 @@ public class CloudEventHttpOutgoingDecorator implements MessageDecorator { */ @Override public Message decorate(Message message) { - return message.addMetadata(HTTP_RESPONSE_METADATA); + return message.getMetadata(OutgoingCloudEventMetadata.class).isEmpty() ? message.addMetadata(HTTP_RESPONSE_METADATA) : message.addMetadata(HTTP_BINARY_RESPONSE_METADATA); } }