[jboss-user] [JBoss Seam] - Trying async in 1.1 -- behaves like sync

rdewell do-not-reply at jboss.com
Mon Oct 30 16:55:40 EST 2006


Thought I'd give this a shot.  We have a process that can occur in the background instead of holding up the display of the next page.  Perfect candidate for async. 

So I created a stateless test bean to call during another form submission / action:


  | @Stateless
  | @Name("OrderProcessor")
  | @Interceptors(SeamInterceptor.class)
  | public class OrderProcessorImpl implements OrderProcessor, Serializable{
  |  private static final long serialVersionUID = -8591335166721681758L;
  | 
  | 	@Asynchronous
  | 	public void process(@Duration long initialStartMS, String id) {
  | 		LOG.info("Processing: " + id);
  | 		
  | 		try {
  | 			Thread.currentThread().sleep(1000 * 30);
  | 		} catch (InterruptedException e) {
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 

The 30 second sleep in there just simulates some long running logic in the method.

I expected to:

- Have the submitted action that calls this async method to return almost immediately with a view.
- In 60 seconds (which is what I pass in the duration param), see the "Processing: XYZ" in the logs.
- Of course have the currently submitted action be unaffected by either the 60 seconds passed in as the init duration, and definitely not affected by the 30 second sleep..

But instead:

- Almost immediately after submitting the form action I see in the logs:  "Processing: xyz"..  
- A full 30 seconds goes by before my view returns from the action that was called (the action which called the async).

?



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981877#3981877

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981877



More information about the jboss-user mailing list