• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
asynchronous processing in WOLongResponsePage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

asynchronous processing in WOLongResponsePage


  • Subject: asynchronous processing in WOLongResponsePage
  • From: Michael Engelhart <email@hidden>
  • Date: Wed, 22 Sep 2004 11:42:09 -0500

Hi -

I have a need to access multiple XML (web services) feeds from multiple sources in the same response so I can aggregate the data into the format my users need to see it. I've created a first attempt at this and it works in my simple tests but am wondering if anyone who has more experience in this can chime in and tell me if this is going to cause problems when there are many concurrent users using the site.

Basically I have three classes to support this per XML feed.

1) XMLFeedThread which is the worker class that does the work
2) XMLFeedEvent which is a class that is generated by the XMLFeedThread and stuffed with the results of the web services call.
3) XMLFeedEventListener which is an interface that has a single method like:
public void xmlFeedReturned(XMLFeedEvent evt);


Right now I have my WOLongResponsePage implementing XMLFeedEventListener and then the XMLFeedEvent's are sent to that page which stores the responses in an NSArray and then when all the web services results are in the NSArray, I call the page that displays the results. I have this code in my performAction() method to poll so that the page won't forward on before all the results are returned (wsFeed is the NSArray storing the result objects)

while (true) {
	if (wsFeed.count() == 3) {
		break;
	} else {
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}

This seems clunky to me but after scouring the web I couldn't find any examples of how one might do this in any request/response based web system. One thing I wasn't sure of is whether calling Thread.sleep() calls the exact thread that the WOLongResponsePage is actually in. According to the docs it does but I didn't feel all warm and fuzzy about it :-)

Originally I was investigating Java's built-in Observer pattern classes but couldn't get them to work the way I needed in my setup. I also realize that WO has a Notification mechanism that does this as well but I was trying to be "application server independent" with my code and I don't need anything fancy so the simple EventListener paradigm used by AWT seemed reasonable.

What I'd like advice on is the polling part. It seems that there could be a cleaner way to process this either by starting the threads in the previous page or something but I haven't come up with anything.

Thanks
Mike

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Sorting question
  • Next by Date: Re: Sorting question
  • Previous by thread: Re: Sorting question
  • Next by thread: Architectural question regarding WOComonent Actions and Frameworks
  • Index(es):
    • Date
    • Thread