Delivery Process
The Delivery Process service is used to deliver data associated with a completed submission, including submitted form XML, file attachments and the PDF receipt document to external systems.
Service Invoke Parameters
Parameter | Description | Nullable |
---|---|---|
svcDef | the service definition value object, see SvcDef | no |
txn | the transaction record value object, see Txn | no |
Error Handling
Submission delivery is performed asynchronously by a background job. If a delivery process error occurs the end user will never see this error.
If an exception is thrown by the Delivery Process, the SubmissionDeliveryController
will make the submission delivery status
Error
and will log the error in the Journey Manager database error log.
Please note the SubmissionDeliveryController will rollback the current delivery transaction if an unhandled error is thrown by the Delivery Process. Any Journey Manager database changed performed by the Groovy Script will be rolled back with the transaction, including any delivery checkpoint changes.
If the Service Definition is configured to perform a number of automatic retry attempts, then the submission will be scheduled to retry delivery after the configured period of time.
Service Template
This section shows service template Groovy script.
import com.avoka.tm.util.*
import com.avoka.tm.vo.*
class FluentDeliveryProcess {
// Injected at runtime
public Logger logger
/*
* Perform Transaction Delivery Process
*
* returns: null if completed or DeliveryResult objet
*/
DeliveryResult invoke(SvcDef svcDef, Txn txn) {
try {
// TODO: perform delivery work
return new DeliveryResultBuilder()
.setStatus(Txn.DELIVERY_COMPLETED)
.build()
} catch (Exception e) {
return new DeliveryResultBuilder()
.setMaxDeliveryAttempts(5)
.setMessage(e)
.setNextDeliveryMins(30)
.setStatus(Txn.DELIVERY_ERROR)
.build()
}
}
}}
Unit Test Template
This section shows unit test template Groovy script.
import com.avoka.tm.svc.*
import com.avoka.tm.test.*
import com.avoka.tm.util.*
import com.avoka.tm.vo.*
import org.junit.*
class UnitTest extends AbstractJUnitTest {
// Injected at runtime
public static Logger logger
/*
* Perform service unit test
*
* throws: exception if unit test fails
*/
@Test
void testDeliveryCompleted() throws Exception {
String xmlData = testParams['Test XML Data']
Txn txn = new MockVoBuilder().createTxnDeliveryReadyWithXml(xmlData)
Map params = [
"svcDef": svcDef,
"txn": txn
]
DeliveryResult result = (DeliveryResult) new ServiceInvoker(svcDef).invoke(params)
// Check result
logger.info result
assert result.status == Txn.DELIVERY_COMPLETED
}
}