Collect After Submit
A common Service pattern is to submit all of your requests, then wait for the results. When using this pattern, the AFTER_SUBMIT collection mode must be used. This enables optimal submission without network competition from the collection.
When this mode is used, the collection of the results begins when either Service.waitUntilInactive(long) or Service.destroyWhenInactive() is called.
Also, when using this mode or even when using some hybrid pattern that submits many requests at a time, Options.INVOCATIONS_PER_MESSAGE must always be set greater than one, to speed submission time.
Calling Service.execute(String methodname, Object data) does not work with this collection type; an instance of ServiceException is thrown.
The following is an example of using the AFTER_SUBMIT collection mode:
Properties props = new Properties();
props.setProperty(Options.COLLECTION_TYPE,
Options.Collection.AFTER_SUBMIT);
props.setProperty(Options.INVOCATIONS_PER_MESSAGE, "20");
Service s = ServiceFactory.getInstance().createService(serviceType, null, props, null);
// submit all the work
for (int i = 0; i < numInputs; i++) {
s.submit("myMethod", getData(i), handler);
}
s.waitUntilInactive();
Fault Tolerance
In the event of a Driver failure, the Broker automatically cancels the Service after the interval specified by the Client Timeout setting. It is possible to collect tasks from a failed client application for Services of type Collection.AFTER_SUBMIT and Collection.IMMEDIATELY if cancelslation has not yet occurred. To do this, you must collect and pass in the Driver session ID, in the same fashion as the collection of a Collection.LATER Service, as described in Deferred Collection (Collect Later).
Note that for fault tolerance to work, the collecting Driver must be the same platform as the original submitting Driver. That is, if the Service was created with Java Driver, it must also be collected with Java Driver.