Request Processor
Request Processor is a part of the Payment Entries Processor whose role is to process a previously built Request.
The RequestProcessor interface does not specify how the sending should look.
It is left to the implementation class to implement the sending logic.
Example Request Processor implementations
It is possible to consider how an implementation might look, if we were processing a request to release a payment or to cancel a payment.
Example Payment Request Processor
If we are processing a payment, we might define something similar to this:
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.connector.SendConnector;
import com.iconsolutions.ipf.core.releaser.service.release.RequestProcessor;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import com.iconsolutions.ipf.payments.credittransfer.executepayment.api.ExecutePaymentRequest;
import lombok.RequiredArgsConstructor;
import reactor.core.publisher.Mono;
@RequiredArgsConstructor
public class ExamplePaymentRequestProcessor implements RequestProcessor<ExecutePaymentRequest> {
private final SendConnector<ExecutePaymentRequest, ExecutePaymentRequest> executePaymentSendConnector;
@Override
public Mono<UnitOfWorkId> process(ExecutePaymentRequest paymentRequest) {
return Mono.fromCompletionStage(executePaymentSendConnector.send(paymentRequest.getProcessingContext(), paymentRequest))
.handle((deliveryOutcome, sink) -> {
if (deliveryOutcome.getDeliveryReport().isSuccess()) {
sink.next(UnitOfWorkId.createRandom());
} else {
sink.error(deliveryOutcome.getDeliveryReport().getDeliveryException());
}
});
}
}
Here we are handling the sending of an ExecutePaymentRequest request using a connector and handling the response.
Example Payment Cancel Processor
If we are cancelling a payment, we might define something similar to this:
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.releaser.service.release.RequestProcessor;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
import exampledomain.domain.ExampleDomain;
import exampledomain.inputs.ExampleCancellationInput;
import reactor.core.publisher.Mono;
import java.util.UUID;
public class ExampleCancelRequestProcessor implements RequestProcessor<InitCancellationFlowRequest> {
@Override
public Mono<UnitOfWorkId> process(InitCancellationFlowRequest request) {
var uofwid = request.getUnitOfWorkId();
var exampleCancellationInput = new ExampleCancellationInput.Builder(uofwid.getValue())
.build();
return Mono.fromCompletionStage(
ExampleDomain
.initiation()
.handle(exampleCancellationInput)
.thenApply(done -> uofwid)
);
}
}
package com.iconsolutions.ipf.core.releaser;
import com.iconsolutions.ipf.core.shared.domain.context.UnitOfWorkId;
@Getter
@Builder
public class InitCancellationFlowRequest {
private UnitOfWorkId unitOfWorkId;
}
Here we are handling the processing of an InitCancellationFlowRequest and passing it into an ExampleDomain for processing.
In doing this it could, for example, be used for initialising a Cancellation Flow.