in serverless-workflow-examples/serverless-workflow-loanbroker-showcase/aggregator/src/main/java/org/acme/serverless/loanbroker/aggregator/CloudEventsConverter.java [44:60]
public <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException {
if (CloudEvent.class.equals(type)) {
// In real-life use case, this can be a Any Object -> CloudEvents conversion.
// One can keep the specific CE attributes in the Exchange header or attributes.
final CloudEvent event = CloudEventBuilder.v1()
.withId(UUID.randomUUID().toString())
.withType("kogito.serverless.loanbroker.aggregated.quotes.response")
.withSource(URI.create("/kogito/serverless/loanbroker/aggregator"))
.withDataContentType(MediaType.APPLICATION_JSON)
.withData(PojoCloudEventData.wrap(value, mapper::writeValueAsBytes))
.withExtension(KOGITO_FLOW_ID_HEADER,
exchange.getIn().getHeader(KOGITO_FLOW_ID_HEADER).toString())
.build();
return (T) event;
}
return null;
}