Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Attribute

Required?

Description

Default Value

name

Y

The unique name of the service.

 

engine

Y

The name of the engine (defined in serviceengine.xml).

 

location

N

The location or package of the service's class.

 

invoke

N

The method name of the service.

 

auth

N

Does this service require authorization? (true/false)

true

debug

N

Enable verbose debugging when calling this service?

true

default-entity-name

N

The default Entity to use for auto-attributes

 

export

N

Is this service allowed to be accessed via SOAP/HTTP/JMS? (true/false)

false

max-retry

N

Sets the max number of times this service will retry when failed (persisted async only)

-1 (unlimited)

require-new-transaction

N

Require a new transaction for this service

true

semaphore

N

Defines how concurrent calls to this service should be handled:
none: multiple calls to this service may run concurrently
wait: while this service is running, queue any subsequent calls
fail: while this service is running, fail any subsequent calls

none

semaphore-wait-seconds

N

When semaphore="wait" how many seconds to wait before failing the service call

300

sempahore-sleep

N

When semaphore="wait" how often (in milliseconds) to check if the waiting service call can be run

500

validate

N

Do we validate the attributes found below for name and type matching? (true/false)

true

...



Now look at the console and see what the test service has echoed.
The test service is located in core/docs/examples/ServiceTest.java You must compile this and place it in the classpath.

To schedule a service to run at a later time or to repeat use this:

Code Block
// This example will schedule a job to run now.
Map context = UtilMisc.toMap("message","This is a test.");
try {
    long startTime = (new Date()).getTime();
    dispatcher.schedule("testScv", context, startTime);
} catch (GenericServiceException e) {     e.printStackTrace();



// This example will schedule a service to run now and repeat once every 5 seconds a total of 10 times.
Map context = UtilMisc.toMap("message","This is a test.");
try {
    long startTime = (new Date()).getTime();
    int frequency = RecurrenceRule.SECONDLY;
    int interval = 5;
    int count = 10;
    dispatcher.schedule("testScv", context, startTime, frequency, interval, count);
} catch (GenericServiceException e) {
    e.printStackTrace();
}

...