fferpcore.LinkingMessageHandlerglobal with sharing class LinkingMessageHandler A fferpcore.LinkingMessageHandler structure. Methods
LinkingMessageHandlerglobal LinkingMessageHandler(Schema.SObjectType recipientObject, fferpcore.LinkingCorrelationStrategy correlation, fferpcore.LinkingMessageToObjectMarshaller marshaller, String linkDeveloperName) The constructor used to create a fferpcore.LinkingMessageHandler object. This constructor is used to define what SObject type is to be created, how it will be linked together and where the link comes from. Input Parameters
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. //This is the subscribers handler class global class HCMUpdateResourceHandler implements fferpcore.MessageHandler { public static final String LINK_DEVELOPER_NAME = 'HCM'; public static final String PRODUCT_DEVELOPER_NAME = 'HCM'; public static final String RESOURCE_LINK_CONTROL_MESSAGE_TYPE = 'Resource.LinkControl'; public void onMessages(fferpcore.HandleMessagesRequest request) { List<fferpcore.DeliveredMessage> messages = request.getMessages(); fferpcore.SubscriptionDescription description = fferpcore.SubscriptionDescriptionService.getDescription(PRODUCT_DEVELOPER_NAME, UpdateResourceMessage.TYPE_NAME).getDescription(); fferpcore.LinkingCorrelationStrategy correlation = new fferpcore.SimpleLinkingCorrelationStrategy(HCMFakeWorker__c.EmployeeId__c); fferpcore.LinkingMessageHandler linkingMessageHandler = new fferpcore.LinkingMessageHandler(HCMFakeWorker__c.SObjectType, correlation, description, LINK_DEVELOPER_NAME); fferpcore.LinkingMessageHandlerResult result = linkingMessageHandler.onMessages(messages); fferpcore.MessagingSystemService.deliverNow(PRODUCT_DEVELOPER_NAME, result.createMessageRequestsFor(RESOURCE_LINK_CONTROL_MESSAGE_TYPE)); } } withAllowCreateglobal fferpcore.LinkingMessageHandler withAllowCreate(Boolean value) Determines whether this handler is able to create new records. If true, this handler creates a new record if the correlation strategy does not return a record. If false, this handler reports an error if the correlation strategy does not return a record. The correlation strategy can create and return new records regardless of this setting. The default value is true. onMessagesglobal fferpcore.LinkingMessageHandlerResult onMessages(List<fferpcore.DeliveredMessage> messages) This method takes a list of delivered messages and selects a list of all the correlation IDs from those messages. With this list, it then selects a list of all the objects with the correlation IDs of the specified type and, if they exist, tries to update them. Otherwise, it tries to create a new object. When this has been done, it returns information about the creation and updating of objects. Input Parameters
Return ValueThis service returns a LinkingMessageHandlerResult object. 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. //This is the subscribers handler class global class HCMUpdateResourceHandler implements fferpcore.MessageHandler { public static final String LINK_DEVELOPER_NAME = 'HCM'; public static final String PRODUCT_DEVELOPER_NAME = 'HCM'; public static final String RESOURCE_LINK_CONTROL_MESSAGE_TYPE = 'Resource.LinkControl'; public void onMessages(fferpcore.HandleMessagesRequest request) { List<fferpcore.DeliveredMessage> messages = request.getMessages(); fferpcore.SubscriptionDescription description = fferpcore.SubscriptionDescriptionService.getDescription(PRODUCT_DEVELOPER_NAME, UpdateResourceMessage.TYPE_NAME).getDescription(); fferpcore.LinkingCorrelationStrategy correlation = new fferpcore.SimpleLinkingCorrelationStrategy(HCMFakeWorker__c.EmployeeId__c); fferpcore.LinkingMessageHandler linkingMessageHandler = new fferpcore.LinkingMessageHandler(HCMFakeWorker__c.SObjectType, correlation, description, LINK_DEVELOPER_NAME); fferpcore.LinkingMessageHandlerResult result = linkingMessageHandler.onMessages(messages); fferpcore.MessagingSystemService.deliverNow(PRODUCT_DEVELOPER_NAME, result.createMessageRequestsFor(RESOURCE_LINK_CONTROL_MESSAGE_TYPE)); } } |