Foundations Apex API Developer Reference


global interface MessageHandler

Interface used by fferpcore to call out to message handlers.



void onMessages(fferpcore.HandleMessagesRequest request)

This method handles all messages that are sent to this handler. This method must be implemented by a class which implementes MessageHandler. Fferpcore will call this method in a "with sharing" context. The Current User fferpcore.Context will be the user performing an action that generates a synchronous message or the messaging batch user. Care must be taken if your code validates user access rights using SObject Describe.

Input Parameters

Name Type Description
request fferpcore.HandleMessagesRequest This object should contain a list of messages associated with this handler.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

 * A message handler that rejects messages that do not contain the expected text.
global class MyMessageHandlerImpl implements fferpcore.MessageHandler
    global void onMessages(fferpcore.HandleMessagesRequest request)
        // This handler uses handler data for configuration. The handler data is the expected string.
        String expectedContent = handlerData.get('ExpectedContent');
        for(fferpcore.DeliveredMessage message : request.getMessages())
            if(message.getBody() != expectedContent)
                message.respondError(new fferpcore.ErpErrorBody('You sent the wrong message'));
            // Otherwise it was OK. Allow the framework to mark is as such.
© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.