![]() ERP Core API Developer Reference
|
fferpcore.MessagingSystemServiceglobal with sharing class MessagingSystemService This class is the main entry point for the ERP Messaging System. Developers can invoke the deliverNow and deliverLater methods to send messages. Methods
deliverNowglobal static fferpcore.MessagingSystemService.DeliverNowResult deliverNow(String sendingProductDeveloperName, List<fferpcore.MessagingSystemService.MessageRequest> requests) Deliver messages synchronously. Messages will have been handled by the recipient before this method returns. This allows immediate communication and, through reply messages, results to be made available immediately. It risks exceeding limits as recipient code runs in the same execution context. As no Product Proxy is specified, it is assumed messages are being sent from the default (managed) Product Proxy. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverNowResult with no content. 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. List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); messageRequests.add(new fferpcore.MessagingSystemService.MessageRequest('messageTypeDeveloperName', 'correlationId', 'body')); fferpcore.MessagingSystemService.deliverNow('productDeveloperName', messageRequests); // Can execute code here knowing that the messages have been handled by the subscribers. deliverNowglobal static fferpcore.MessagingSystemService.DeliverNowResult deliverNow(String productDeveloperName, String messageTypeDeveloperName, fferpcore.DataSource dataSource) This method is a convenient way to build messages using the MessageDescriptionService, then use deliverNow to deliver them. This method may avoid generating messages if it will not be possible to send them. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverNowResult with no content. 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. trigger SampleTrigger on Sample__c (after insert, after update) { // Prevent an infinite loop by not sending a message in response to a message. if (!fferpcore.MessagingSystemService.isInDelivery()) { // Provide the new or updated records as a DataSource for message generation. fferpcore.DataSource dataSource = new fferpcore.TriggerDataSource(Trigger.New); // Send the messages. fferpcore.MessagingSystemService.deliverNow('ProductName', 'MessageTypeName', dataSource); // Can execute code here knowing that the messages have been handled by the subscribers. } } deliverNowglobal static fferpcore.MessagingSystemService.DeliverNowResult deliverNow(fferpcore.MessagingSystemService.Sender sender, List<fferpcore.MessagingSystemService.MessageRequest> requests) Deliver messages synchronously. Messages will have been handled by the recipient before this method returns. This allows immediate communication and, through reply messages, results to be made available immediately. It risks exceeding limits as recipient code runs in the same execution context. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverNowResult with no content. 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. List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); messageRequests.add(new fferpcore.MessagingSystemService.MessageRequest('messageTypeDeveloperName', 'correlationId', 'body')); fferpcore.MessagingSystemService.Sender sender = new fferpcore.MessagingSystemService.Sender('ProductDevName'); fferpcore.MessagingSystemService.deliverNow(sender, messageRequests); // Can execute code here knowing that the messages have been handled by the subscribers. deliverNowglobal static fferpcore.MessagingSystemService.DeliverNowResult deliverNow(fferpcore.MessagingSystemService.Sender sender, fferpcore.MessagingSystemService.MessageTypeSpecifier messageTypeSpecifier, fferpcore.DataSource dataSource) This method is a convenient way to build messages using the MessageDescriptionService, then use deliverNow to deliver them. This method may avoid generating messages if it will not be possible to send them. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverNowResult with no content. 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. trigger SampleTrigger on Sample__c (after insert, after update) { // Prevent an infinite loop by not sending a message in response to a message. if (!fferpcore.MessagingSystemService.isInDelivery()) { // Provide the new or updated records as a DataSource for message generation. fferpcore.DataSource dataSource = new fferpcore.TriggerDataSource(Trigger.New); fferpcore.MessagingSystemService.Sender sender = new fferpcore.MessagingSystemService.Sender('ProductDevName'); fferpcore.MessagingSystemService.MessageTypeSpecifier messageTypeSpecifier = new fferpcore.MessagingSystemService.Sender('Resource.Update', 'Sample__c'); // Send the messages. fferpcore.MessagingSystemService.deliverNow(sender, messageTypeSpecifier, dataSource); // Can execute code here knowing that the messages have been handled by the subscribers. } } isInDeliveryglobal static Boolean isInDelivery() Return ValueTrue if a delivery is currently in progress. 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. /** * @return true if the report was successfully created */ public Boolean createExpensesReport() { //If the messaging system is still delivering messages, we shouldn't do the report as we won't have all the data we want if(fferpcore.MessagingSystemService.isInDelivery()) { return false; } //Actually create report ... } deliverLaterglobal static fferpcore.MessagingSystemService.DeliverLaterResult deliverLater(String sendingProductDeveloperName, List<fferpcore.MessagingSystemService.MessageRequest> requests) Send messages asynchronously. For each message, if the sending product is enabled to send to the message's message type, then a MessagingMessage__c is created for later delivery by the batch message delivery system. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverLaterResult with no content. 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. List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); messageRequests.add(new fferpcore.MessagingSystemService.MessageRequest('messageTypeDeveloperName', 'correlationId', 'body')); fferpcore.MessagingSystemService.deliverLater('productDeveloperName', messageRequests); deliverLaterglobal static fferpcore.MessagingSystemService.DeliverLaterResult deliverLater(String productDeveloperName, String messageTypeDeveloperName, fferpcore.DataSource dataSource) Convenience method to build messages using the MessageDescriptionService, then use deliverLater to deliver them. This method may avoid generating messages if it will not be possible to send them. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverLaterResult with no content. 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. trigger SampleTrigger on Sample__c (after insert, after update) { // Prevent an infinite loop by not sending a message in response to a message. if (!fferpcore.MessagingSystemService.isInDelivery()) { // Provide the new or updated records as a DataSource for message generation. fferpcore.DataSource dataSource = new fferpcore.TriggerDataSource(Trigger.New); // Send the messages. They will be saved to the DB now. The subscription handlers will process them later. fferpcore.MessagingSystemService.deliverLater('ProductName', 'MessageTypeName', dataSource); } } deliverLaterglobal static fferpcore.MessagingSystemService.DeliverLaterResult deliverLater(fferpcore.MessagingSystemService.Sender sender, List<fferpcore.MessagingSystemService.MessageRequest> requests) Send messages asynchronously. For each message, if the sending product is enabled to send to the message's message type, then a MessagingMessage__c is created for later delivery by the batch message delivery system. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverLaterResult with no content. 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. List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); messageRequests.add(new fferpcore.MessagingSystemService.MessageRequest('messageTypeDeveloperName', 'correlationId', 'body')); fferpcore.MessagingSystemService.Sender sender = new fferpcore.MessagingSystemService.Sender('ProductDevName'); fferpcore.MessagingSystemService.deliverLater(sender, messageRequests); deliverLaterglobal static fferpcore.MessagingSystemService.DeliverLaterResult deliverLater(fferpcore.MessagingSystemService.Sender sender, fferpcore.MessagingSystemService.MessageTypeSpecifier messageTypeSpecifier, fferpcore.DataSource dataSource) Convenience method to build messages using the MessageDescriptionService, then use deliverLater to deliver them. This method may avoid generating messages if it will not be possible to send them. Input Parameters
Return ValueThis class always returns a fferpcore.DeliverLaterResult with no content. 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. trigger SampleTrigger on Sample__c (after insert, after update) { // Prevent an infinite loop by not sending a message in response to a message. if (!fferpcore.MessagingSystemService.isInDelivery()) { // Provide the new or updated records as a DataSource for message generation. fferpcore.DataSource dataSource = new fferpcore.TriggerDataSource(Trigger.New); fferpcore.MessagingSystemService.Sender sender = new fferpcore.MessagingSystemService.Sender('ProductDevName'); fferpcore.MessagingSystemService.MessageTypeSpecifier messageTypeSpecifier = new fferpcore.MessagingSystemService.Sender('Resource.Update', 'Sample__c'); // Send the messages. They will be saved to the DB now. The subscription handlers will process them later. fferpcore.MessagingSystemService.deliverLater(sender, messageTypeSpecifier, dataSource); } } isInBatchDeliveryglobal static Boolean isInBatchDelivery() Return ValueTrue if a batch job is currently in progress. 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 MessageHandler's onMessages method will be invoked when the subscription it is associated to * receives messages from a publication of the same message type. */ public class ExampleHandler implements fferpcore.MessageHandler { public void onMessages(fferpcore.HandleMessagesRequest request) { for(fferpcore.DeliveredMessage message : request.getMessages()) { s_deliveredMessages.add(message); message.respondSuccess(); if(fferpcore.MessagingSystemService.isInBatchDelivery()) { //Code when this handler receiving messages is in batch } } } } isDormantglobal static Boolean isDormant() Return ValueTrue if the current endpoints would cause no new messages to be sent. Dormant does not prevent delivery. of existing messages. 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. if (!fferpcore.MessagingSystemService.isDormant()) { //Create messages and requests. } fferpcore.MessagingSystemService.MessageRequestglobal virtual class MessageRequest A request to send a Message. Methods
MessageRequestglobal MessageRequest(String messageTypeDeveloperName, String correlationId, String body) Input Parameters
MessageRequestglobal MessageRequest(fferpcore.MessagingSystemService.MessageTypeSpecifier messageTypeSpecifier, String correlationId, String body) Input Parameters
getMessageTypeDeveloperNameglobal String getMessageTypeDeveloperName() Return ValueThe developer name of the message type associated with this request. getMessageTypeSpecifierglobal virtual fferpcore.MessagingSystemService.MessageTypeSpecifier getMessageTypeSpecifier() Return ValueThe qualified message type of this request. getCorrelationIdglobal String getCorrelationId() Return ValueThe correlation Id associated with this request. equalsglobal Boolean equals(Object obj) This compares all the values between the method caller and the object provided. This ensures that the two objects are of the same type and that all the data on the object is identical. Input Parameters
hashcodeglobal Integer hashcode() Return ValueA hashcode based on all the information on the object. fferpcore.MessagingSystemService.DeliverNowResultglobal class DeliverNowResult A currently empty result allows us to add result information later while keeping within Salesforce's upgrade restrictions. fferpcore.MessagingSystemService.DeliverLaterResultglobal class DeliverLaterResult A currently empty result allows us to add result information later while keeping within Salesforce's upgrade restrictions. fferpcore.MessagingSystemService.Senderglobal class Sender A class that wraps up information about who is sending the message. It combines a Product and a ProductProxy. Methods
Senderglobal Sender(String productDeveloperName) Creates a Sender for the specified product and the Managed Product Proxy. This method is a convenience for calling MessagingSystemService.Sender(product, ProductProxies.MANAGED_PROXY_DEVELOPER_NAME). Input Parameters
Senderglobal Sender(String productDeveloperName, String productProxyDeveloperName) Creates a Sender from the specified product and proxy. Input Parameters
getProductDeveloperNameglobal String getProductDeveloperName() Return ValueReturns the developerName of the Product. getProductProxyDeveloperNameglobal String getProductProxyDeveloperName() Return ValueThe developerName of the proxy that the product is sending on behalf of. fferpcore.MessagingSystemService.MessageTypeSpecifierglobal class MessageTypeSpecifier A class that contains information about the type of message sent in a particular request. It contains the message type, and also a identifier. A product/proxy can have different publications for the same message type if they have different identifiers. This class is used to identify the publication a product/proxy wishes to send on. Methods
MessageTypeSpecifierglobal MessageTypeSpecifier(String messageTypeDeveloperName, String identifier) Creates a MessageTypeSpecifier from the supplied MessageType and Identifier Input Parameters
MessageTypeSpecifierglobal MessageTypeSpecifier(String messageTypeDeveloperName) Creates a MessageTypeSpecifier from the supplied MessageType and no Identifier Input Parameters
getMessageTypeDeveloperNameglobal String getMessageTypeDeveloperName() Return ValueThe developerName of the messageType. getIdentifierglobal String getIdentifier() Return ValueThe identifier used when this object was constructed. |