THIS IS A RESEND SINCE MODERATOR STOPPED LAST REPLY FOR 9KB OVER! --------------------------------------------- Or if you don't want to use concurrent request handling, you can dispatch this request in a thread of its own. That way the request generating this DA request gets completed and thus frees up the ap to answer the spun-off second request.
Here is a snippet example from a ScheduledTaskDetail WOComponent where I fire a direct action at my current development instance for testing scheduled task direct actions. devFireEvent is a simple component action invoked by a WOHyperlink and DevFireEvent is an inner class in the WOComponent class. the request associated with invoking devFireEvent completes and returns before the direct action request it spawned gets handled in the run() method of the inner class. Never mind the superfluous details ... but this gives you a way to do it without turning on Concurrent Request Handling if that is something you want not to do. ... note the httpConn.sendRequest and readResponse are in running in the separate thread......
HTH, Kieran
/** Usable in development mode only for developer testing. Must fire the request in a separate thread since this request will block because AllowsConcurrentRequestHandling is off. */ public WOComponent devFireEvent() { Thread devFireEventThread = new DevFireEvent( selectedTaskEvent() ); devFireEventThread.start(); return null; } protected class DevFireEvent extends Thread { protected CTScheduledTaskEvent event; protected EOEditingContext ec; public DevFireEvent() { super(); } /** Create a local instance in a manual lock EC */ public DevFireEvent( CTScheduledTaskEvent newEvent ) { super();
ec = WKEditingContext.createInstance(); ec.lock(); try { event = (CTScheduledTaskEvent)EOUtilities.localInstanceOfObject( ec, newEvent ); } catch ( Exception e ) { log.error( "Error creating DevFireEvent with " + WKStringUtilities.toString( newEvent ), e ); } finally { ec.unlock(); }
} /** Fire the event */ public void run() { ec.lock(); try { int portNumber = ERXProperties.intForKeyWithDefault( "singletonOperations.fireEvent.portNumber", 80 ); String targetHostName = System.getProperty( "singletonOperations.fireEvent.targetHostName" ); WOHTTPConnection httpConn = new WOHTTPConnection( targetHostName, portNumber ); String url = "" "singletonOperations.fireEvent.baseUrl" ); url = "" + "?keycode=" + event.keycode(); if ( log.isDebugEnabled() ) log.debug("fireEvent url = ""Apple-style-span" face="Monaco" size="2"> + url ); WORequest request = new WORequest( "GET", url, "HTTP/1.1", null, null, null ); httpConn.sendRequest( request ); WOResponse response = httpConn.readResponse(); } catch ( Exception e ) { log.error( "Error firing event " + WKStringUtilities.toString( event ), e ); } finally { ec.unlock(); } } } On Oct 9, 2006, at 6:01 PM, Mike Schrag wrote: Random tidbit ... Be careful of using this to call back into yourself (i.e. App A connecting back to App A). You want to make sure you have concurrent request handling turned on or you will deadlock yourself.
ms |