class MessageProcessorProxy {

    public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException {
        log.info("Invoking message processor lambda to process {} messages", request.getMessages().size());
        String requestPayload = GSON.toJson(request);

        InvokeRequest invokeRequest = new InvokeRequest()
                .withFunctionName(messageProcessorFunctionName)
                .withInvocationType(InvocationType.RequestResponse)
                .withPayload(requestPayload);

        InvokeResult result = lambda.invoke(invokeRequest);

        if (result.getFunctionError() != null) {
            throw new MessageProcessorException(result);
        }

        return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class);
    }

}