use of org.mule.runtime.api.component.execution.InputEvent in project mule by mulesoft.
the class AbstractExecutableComponent method execute.
@Override
public final CompletableFuture<ExecutionResult> execute(InputEvent inputEvent) {
CompletableFuture completableFuture = new CompletableFuture();
CoreEvent.Builder builder = CoreEvent.builder(createEventContext(of(completableFuture)));
CoreEvent event = builder.message(inputEvent.getMessage()).error(inputEvent.getError().orElse(null)).variables(inputEvent.getVariables()).build();
return from(MessageProcessors.process(event, getExecutableFunction())).onErrorMap(throwable -> {
MessagingException messagingException = (MessagingException) throwable;
CoreEvent messagingExceptionEvent = messagingException.getEvent();
return new ComponentExecutionException(messagingExceptionEvent.getError().get().getCause(), messagingExceptionEvent);
}).<ExecutionResult>map(result -> new ExecutionResultImplementation(result, completableFuture)).toFuture();
}
Aggregations