Version: 19.11 (EOL)
Scheduled Service
The Scheduled Service provides a Groovy service which can be called at a scheduled time using a configured ScheduledServiceJob
instance. This is useful for performing background jobs at regular or scheduled times.
This service is configured via System > Scheduled Jobs.
You also need to configure a new Scheduled Service job instance to call your named service. See the example Scheduled Service job definition below.
Service Invoke Parameters
Parameters are not nullable except where otherwise indicated.
Parameter | Description |
---|---|
svcDef | SvcDef A service definition value object. |
Error Handling
If an error occurs invoking the Scheduled Service, the error is recorded in the Journey Manager database error log.
Templates
Service
import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.vo.*
class FluentScheduledService {
/*
* Perform scheduled job
*
* returns: string message to be logged to the server log as an INFO message
*/
String invoke(SvcDef svcDef) {
// TODO: perform business logic
return 'Schedule Service invoked'
}
}
Unit Test
import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.util.*
import com.avoka.tm.svc.*
import com.avoka.tm.vo.*
import org.junit.Test
class UnitTest extends AbstractJUnitTest {
/*
* Perform service unit test
*
* throws exception if unit test fails
*/
@Test
void testScheduledService() throws Exception {
Map params = [:]
params.svcDef = svcDef
String result = (String) new ServiceInvoker(svcDef).invoke(params)
logger.info result
assert result == 'Schedule Service invoked'
}
}