can some help me with the thread.sleep
i want to execute a flow service that has 2 adapter services
i want to run the first adapter service first and give a 1 minute wait time and execute the second adapter service can i use the threrad.sleep or can i use the sync.wait
SEQUENCE
FLOWSERVICEXYZ
>>>ADAPTER SERVICE A
>>>THREAD.SLEEP/WAIT
>>>>ADAPTER SERVICE B
SEQUENCE
Is your requirement to always wait for a minute before kicking off the second adapter service? If so, you can create a simple java service modeled after the sample.threads.utils.stall java service located in WmSamples. This will force a sleep of n seconds after adapter service A completes.
If, on the other hand, you want to wait UP TO one minute after invoking adapter service A, before kicking off adapter service B, then you’ll need to create a java service that uses the Service.doThreadedInvoke() API method to invoke a Flow or java service on its own thread.
When the service that is invoked completes, it needs to return its results using pub.sync:notify using a key that you pass to it. I prefer to wrap pub.sync:notify with my own java service in order to provide a means of returning exception info from a service invoked on a separate thread.
Your calling service calls your doThreadedInvoke service to kick of adapter service a, then invokes pub.sync:wait with a wait time of n seconds. If the wait time expires before adapter service A returns results, your pub.sync:wait will throw an exception. You can wrap this in a try-catch structure so that your catch behavior can be changed to not throw an exception, but simply to continue processing with adapter service B.
See this post for additional comments on exception handling in service invoked using doThreadedInvoke.
Mark i have used sleep misc.sleep service its working fine for me now
but i am not sure its the right functionality i am using to stop the adapter service for one minute and start the second adapter seevice,
Mark carlson can u please be more specific with the jave code for implementing the the Service.doThreadedInvoke() so that i can work around with this and look if it works for me,
The WmSamples packages has an example in the threads folder.
Basically you do the following:
build an IData with the inputs to the service you wish to invoke (this is often done by making a deep or shallow clone of an input document) []insert a variable called “key” into that IData that contains the key of the service to be notified with the results. []invoke your service using something like this:
[quote]
ServiceThread st = null; st=Service.doThreadInvoke(svcName, inputClone);
[/quote]
[*]the invoked service is responsible for invoking pub.sync:notify using the key inserted into the input document to return its results to the waiting service. Note: if the invoked service throws an exception, nothing will catch it and its results will not be returned. Hence the suggestion to wrap pub.sync:notify so that it returns a return code and an error message if some exception has occurred
HTH,
Lots more discussion on doThreadedInvoke is available in past forum messages. The search function is your friend.