Foundations Apex API Developer Reference

fferpcore.MessagingRedeliveryService

global with sharing class MessagingRedeliveryService

A messaging redelivery service structure.

Methods

canRedeliver

global static List<fferpcore.MessagingRedeliveryService.CanRedeliverResult> canRedeliver(List<Id> deliveryIds)

This method is used to determine if a list of delivery IDs contains any failed deliveries.

Input Parameters

Name Type Description
deliveryIds List<Id> All of the deliveries that are to be checked for any failures.

Return Value

This service returns a list of MessagingRedeliveryService.CanRedeliverResult objects.

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.MessagingDelivery__c>; deliveryObjects = new List<fferpcore.MessagingDelivery__c>();
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Successful'));
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Error'));

insert deliveryObjects;

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(2, deliveryObjects.size);

List<fferpcore.MessagingRedeliveryService.CanRedeliverResult> results = fferpcore.MessagingRedeliveryService.canRedeliver(new List<Id>{deliveryObjects[0].Id, deliveryObjects[1].Id});

System.assertEquals(false, results[0].isRedeliverable());
System.assertEquals(true, results[1].isRedeliverable());

redeliverNow

global static fferpcore.MessagingRedeliveryService.RedeliverNowResult redeliverNow(List<Id> deliveryIds)

This method attempts to redeliver any messages for the deliveries provided to it.

Input Parameters

Name Type Description
deliveryIds List<Id> A list of Ids for deliveries.

Return Value

This service returns an MessagingRedeliveryService.RedeliverNowResult 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.

List<fferpcore.MessagingDelivery__c> deliveryObjects = new List<fferpcore.MessagingDelivery__c>();
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Successful'));
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Error'));        //We will assume that this delivery will now pass
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Exception'));    //We will assume this delivery will still fail

insert deliveryObjects;

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(3, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.RedeliverNowResult results = fferpcore.MessagingRedeliveryService.redeliverNow(new List<Id>{deliveryObjects[0].Id, deliveryObjects[1].Id, deliveryObjects[2].Id});

System.assertEquals(1, results.getNotTriedCount());     //This is for the first delivery
System.assertEquals(1, results.getSuccessCount());      //This is for the second delivery
System.assertEquals(1, results.getErrorCount());        //This is for the third delivery

fferpcore.MessagingRedeliveryService.CanRedeliverResult

global class CanRedeliverResult

A can redeliver result structure. This class is a child class of MessagingRedeliveryService.

Methods

CanRedeliverResult

global CanRedeliverResult(Id deliveryId, Boolean isRedeliverable)

This constructor is used to assign a boolean value to a delivery Id to show if this delivery can be retried.

Input Parameters

Name Type Description
deliveryId Id The Id of the associated delivery.
isRedeliverable Boolean If the delivery can be retried or not.

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.

insert new fferpcore.MessagingDelivery__c(State__c = 'Successful');

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(1, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.CanRedeliverResult result =  new fferpcore.MessagingRedeliveryService.CanRedeliverResult(deliveryObjects[0].Id, false);

System.assertEquals(deliveryObjects[0].Id, result.getDeliveryId());
System.assertEquals(false, result.isRedeliverable());

getDeliveryId

global Id getDeliveryId()

This method is used to return the Id of the delivery that this object is associated to.

Return Value

This service returns an Id 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.

insert new fferpcore.MessagingDelivery__c(State__c = 'Successful');

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(1, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.CanRedeliverResult result =  new fferpcore.MessagingRedeliveryService.CanRedeliverResult(deliveryObjects[0].Id, false);

System.assertEquals(deliveryObjects[0].Id, result.getDeliveryId());
System.assertEquals(false, result.isRedeliverable());

isRedeliverable

global Boolean isRedeliverable()

This method is used to return if the delivery that this object is associated to can be redelivered.

Return Value

This service returns a Boolean 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.

insert new fferpcore.MessagingDelivery__c(State__c = 'Successful');

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(1, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.CanRedeliverResult result =  new fferpcore.MessagingRedeliveryService.CanRedeliverResult(deliveryObjects[0].Id, false);

System.assertEquals(deliveryObjects[0].Id, result.getDeliveryId());
System.assertEquals(false, result.isRedeliverable());

fferpcore.MessagingRedeliveryService.RedeliverNowResult

global class RedeliverNowResult

A redeliver now result structure. This class is a child class of fferpcore.MessagingRedeliveryService

Methods

RedeliverNowResult

global RedeliverNowResult(Integer success, Integer errors)

This constructor is used to assign a value to the success and error variables held within this class. The system will pass a Not Tried Count using the three parameter constructor.

Input Parameters

Name Type Description
success Integer The number of successful redeliveries.
errors Integer The number of failed deliveries.

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.

fferpcore.MessagingRedeliveryService.RedeliverNowResult result = new fferpcore.MessagingRedeliveryService.RedeliverNowResult(1,2);

System.assertEquals(1, results.getSuccessCount());
System.assertEquals(2, results.getErrorCount());

getSuccessCount

global Integer getSuccessCount()

This method returns the number of successful redeliveries.

Return Value

This service returns an Integer 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.

List<fferpcore.MessagingDelivery__c> deliveryObjects = new List<fferpcore.MessagingDelivery__c>();
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Successful'));
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Error'));        //We will assume that this delivery will now pass
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Exception'));    //We will assume this delivery will still fail

insert deliveryObjects;

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(3, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.RedeliverNowResult results = fferpcore.MessagingRedeliveryService.redeliverNow(new List<Id>{deliveryObjects[0].Id, deliveryObjects[1].Id, deliveryObjects[2].Id});

System.assertEquals(1, results.getNotTriedCount());     //This is for the first delivery
System.assertEquals(1, results.getSuccessCount());      //This is for the second delivery
System.assertEquals(1, results.getErrorCount());        //This is for the third delivery

getErrorCount

global Integer getErrorCount()

This method returns the number of failed redeliveries.

Return Value

This service returns an Integer 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.

List<fferpcore.MessagingDelivery__c> deliveryObjects = new List<fferpcore.MessagingDelivery__c>();
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Successful'));
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Error'));        //We will assume that this delivery will now pass
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Exception'));    //We will assume this delivery will still fail

insert deliveryObjects;

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(3, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.RedeliverNowResult results = fferpcore.MessagingRedeliveryService.redeliverNow(new List<Id>{deliveryObjects[0].Id, deliveryObjects[1].Id, deliveryObjects[2].Id});

System.assertEquals(1, results.getNotTriedCount());     //This is for the first delivery
System.assertEquals(1, results.getSuccessCount());      //This is for the second delivery
System.assertEquals(1, results.getErrorCount());        //This is for the third delivery

getNotTriedCount

global Integer getNotTriedCount()

This method returns the number of redeliveries which weren't tried.

Return Value

This service returns an Integer 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.

List<fferpcore.MessagingDelivery__c> deliveryObjects = new List<fferpcore.MessagingDelivery__c>();
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Successful'));
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Error'));        //We will assume that this delivery will now pass
deliveryObjects.add(new fferpcore.MessagingDelivery__c(State__c = 'Exception'));    //We will assume this delivery will still fail

insert deliveryObjects;

deliveryObjects = [SELECT Id FROM fferpcore.MessagingDelivery__c];

System.assertEquals(3, deliveryObjects.size);

fferpcore.MessagingRedeliveryService.RedeliverNowResult results = fferpcore.MessagingRedeliveryService.redeliverNow(new List<Id>{deliveryObjects[0].Id, deliveryObjects[1].Id, deliveryObjects[2].Id});

System.assertEquals(1, results.getNotTriedCount());     //This is for the first delivery
System.assertEquals(1, results.getSuccessCount());      //This is for the second delivery
System.assertEquals(1, results.getErrorCount());        //This is for the third delivery
© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.