Ways to make Java Service run faster

Victor,

Something tells me that there is probably an array transformation or set operation to do this more elegantly, but one approach for improving performance using multi-threading would involve the following steps:

  1. Create a java service that will allow you to invoke Flow or java services on their own thread using the Service.doThreadedInvoke() method. See this post and the WmSamples threads folder for more details and suggestions on how a Flow or java service invoked on a separate thread should report exceptions and return results. []Create a version of your existing java service that only processes a single raw transaction and that returns its results using pub.sync:notify. It will need the unique key generated below to return its results correctly. []In the calling Flow service, use a Repeat statement to invoke a configurable number of services to process your raw transactions. You will need to generate a unique key for each thread. []After each group completes use a separate Repeat statement to “harvest” the results using the pub.sync:wait built-in service using the unique key generated above. Note: the key does not have to be universally unique ID (UUID) but should be unique enough so that you are always certain that you are retrieving the right results. []Use pub.list:appendToDocumentList to add the results of each thread to the documentList containing the accumulated results. []Decide how to handle a thread that encounters an exception (e.g. how will you communicate the error and what will you store in the “orders” documentList for a bad raw transaction. []Conduct performance testing to determine the optimum number of threads to run in parallel.

Hope that helps,
Mark

Thanks Mark for your detailed advice.
We’ll try this out and see how it goes.

Victor