Need to Return immediately and commit the App Module on a different thread
I have an action that I want to return fast (immediately) but the server processing takes longer than acceptable. The results of the operation don't matter to the page submitting it and I want it to be able to navigate away even if the operation is not complete. I want to either be able to send a non-blocking server event from the browser or on the server side start a new thread that performs the operation allowing the original thread to return immediately. The new thread would need access to an Application Module in order to commit data. How would I go about accomplishing this?
Some thoughts
I've tried creating a ConcurrentLinkedQueue and putting the DataControl on the que, then in the other thread I pull it off the que, process and commit the data. This works unless the page is navigated away from. Then calling dc.getApplicationModule(); returns null.
I thought about using createRootApplicationModule in the new thread (since the new thread has no context) but don't know how that would work
This is the code in the run method of the new thread. In this example, I'm adding data to the app module in the original thread and committing the data in a new thread.
(like I said, it works most of the time.)
Object[] req = (Object[])que.poll();
DCDataControl dc = (DCDataControl)req[0];
try{
ApplicationModule am = dc.getApplicationModule();
if (am != null){
am.getTransaction().commit();
} else{
System.out.println("AM:null unable to commit ");
} catch (Exception e){
e.printStackTrace();
finally{
if (dc!= null){ dc.resetState();} // release app module
}
Thanks for the replies. I am aware of the inherent risks of running a separate thread within a managed container.
The use case is a performance logging operation. We have a internal web app used by a network of franchises with over 1000 users. We log response time and performances statistics to the database. When the user clicks to navigate or commit data, the response time that the user experiences is logged after the page has fully rendered either through a PPR or a full submit. This is done by submitting ADFCustomEvent from javascript on the page after rendering is complete.. The event sends up the time difference from when the user first clicked to when the page was fully rendered. This information is then merged with logged events stored on the users Session that shows the name and response time of every query that was executed during the previous request. Depending on the page this could be up to half dozen to a dozen or more queries. The logging operation as experienced by the browser is generally fast (<200ms) but sometimes can be as long as a second or more when the database gets busy. A half second is too long as makes the app appear sluggish if the user can't type or click immediately after the page has finished rendering. The logged data is aggregated so we know exactly how much of the page load was due to a slow browser/network, how much was database time, webservice call time, etc... If it's due to a slow database we can drill down and see which query is the culprit. These performance metrics are critical to operations and are charted throughout the day so we know exactly what our users are experiencing. All of our users use a custom firefox client that we control. Using this logging framework we were able to determine that upgrading to a Firefox 4.0 based client cut browser render time by more than half a second on average. We can also tell what type of hardware the user is running so can place the blame for poor performance where appropriate. We have determined that pages render considerably faster on Windows 7 than on Windows 98 with the same hardware. We are moving the logging tables off of our exadata database to a separate box to remove that load from the application database. Since we expect the other database not to perform as well we don't want it to affect the user experience, hence the need to log asynchronously. I would like to put the data on a queue and have a background daemon process read from the queue and commit to the database. I would like the daemon thread to be able to use BC components. I would prefer not to resort to using a web service because of the inherent overhead. The logging operation is not a long operation but is of high frequency so should be as streamlined as possible. The load is spread over 6 servers with 4 JVM's each (24 weblogic instances). I know it's possible to use BC components from a plain Servlet (which runs on it's own thread) so what I want is to have something like a servlet thread that loops forever processing my logging queue.
One other method I am investigating is using my own non-blocking ajax call that callls a servlet to perform the logging. I will need to pull out the timestamp contained within a client side ADF component along with the pages ctrl-state variable that is included with every ADF request as it uses this as the key to get to the data on the session. ADF really needs a non-blocking ADFCustomEvent for this type of request. (send and don't care about the response)
The client component with the server listener looks like this
<af:outputText value="#{pageFlowScope.perfClientTS}" visible="false"
id="perfClientTSField" clientComponent="true">
<af:serverListener type="logPerfData" method="#{perfLog.logPerfDataAction}"/>
</af:outputText>
The script that queues the ajax call after the page loads looks like this
AdfCustomEvent.queue(perfClientTSField, "logPerfData", {
typeId : typeId,
subTypeId : subTypeId,
responseTime1 : new String(responseTime1),
responseTime2 : new String(responseTime2),
openedVia: via
true);
I also tried calling the noResponseExpected() method on the event before queuing it but it still blocked the UI and caused an additional side effect in that the client sent two ajax requests instead of one. It somehow thought something on the client side needed to be synced with the server.
email me and I can send a doc with more details about how our performance logging framework works.
Edited by: Don Kleppinger on Mar 14, 2012 2:52 PM
Similar Messages
-
why does my apple id in app store settings show one thing and in the apps it shows a different id (ccl43) no email address)
I am unsure what to do I cannot get into my apps account in order to upgrade it. HELP PLEASE!!!!!!It's the Apple ID that app was purchased with.
-
I have installed "Runkeeper" on my iPhone 5. when it opens "connect to itunes to use push notifications" appears. when "OK" is pressed the notification returns immediately and keeps reappearing. the phone at this point is locked and only a reboot will close the app.
I think software on the unit has likely been damaged and needs to be reinstalled, so restore as new will be needed.
-
I've tried to uninstall and reinstall the app but nothing happens. When I try to open the app, it either crashes immediately or asks me for my iTunes password and the the app does nothing or crashes. Has anyone else had this problem? Any suggestions? Also, it seems that my phone asks me for my iTunes password randomly, when I'm not trying to open apps.
The app that I have the most problem with is the Simpsons game. I've tried to contact EA as well as apple and gotten nowhere.
Please help if you have knowledge of what to do
Thanks!If you get an error that says can't backup, try moving the existing backup file to a safe location and thry again. again. You can find the location of the backup file here:
iPhone and iPod touch: About backups -
I have a new iphone and went into Itunes and it said my new iphone needed a software update. I let it do this and now the apps that I put on won't work and when pressed just flash on then off the screen. I paid £20 for one of them so any help would be appreciated.
Memory Map: http://www.memory-map.co.uk/iphone/
0870: http://www.simonmaddox.com/
Viber: http://support.viber.com/home
VoucherCloud: http://questions.vouchercloud.com/ -
Once I open a book in my library there is no option to close it and return to the library. I must leave the app, stop the app and then restart it. How do I exit an opened book to return to my library without having to exit, stop, and restart the app?
Assuming you are talking about "iBooks", then just
tap the center of the screen
and you should see a "Library" in the upper left corner of the screen.
tap the center of the screen again,
and you should return to full screen mode.
if this is NOT iBooks, then I do not know what controls that app -
I have just updated my iPad to IOS 8.1.3 when I now try to open the emails nothing comes up and then the app crashes and returns to the home page. What should I do?
Since yesterday morning about 11:00 I have been having TERRIBLE email problems on this iPad 3G. Email comes in (I hear the sound) but nothing displays -- no folders, no content, no nothing in e-mail. The blank email screen shows up and then disappears after about 10 seconds, taking me back to the Home Screen.
Right now, the only way I can see email on this device is to log onto AOL via the AOL app.
I have been doing a lot of online reading about the problem. It has to do with iOS 8.1.3 and it affects older iPads and iPhones. I'm having no problems on my iPod touch, which -- fortunately -- is so old it cannot update its iOS 6.
I waited to update the iOS on this iPad until iOS 8 was "mature." That was about 2 weeks ago.
Anybody know know if Apple is aware? working on a solution? -
I have been experiencing periodic loss of touch screen response with my iPhone 6 when in landscape mode. Flipping to portrait then back to landscape usually corrects it, but at times I need to close and reenter the app.
Hi McGannahanSkjellyfetti,
If you are experiencing difficulties with touchscreen response on your iPhone I would suggest that you troubleshoot using the steps in this article -
iPhone, iPad, iPod touch: Troubleshooting touchscreen response
Thanks for using Apple Support Communities.
Best,
Brett L -
The screen where my apps show on all the pages is not letting me drag them. The screen looks kind of gray. What do I do to be able to move them to different home screens, and check, and uncheck the apps in the list
The specific demo would need to provide code for touch events.
http://www.w3.org/TR/touch-events/ -
How do I eliminate this glitch? Music spontaneously starts, stops, stutters at random and I'm not even using that app. Repeated attempts to pause the song and close the app have no affect. Just keeps popping on and off randomly no matter what I'm doing at the time. I tried double-clicking the Home button which brings up all of the active apps, touched and held the Music icon until all the icons started wiggling, tapped the Close icon in the upper left corner of the Music app to close the app completely, but the app is still open and still randomly stuttering. I did notice that the play button icon flashes in the upper right corner of the screen when this happens and it appears and disappears in concurrence with the Music app stuttering. When the music starts, the icon appears and when it stops, the icon disappears again. When the music stutters on and off, the icon appears and disappears rapidly and in sync with that random glitch. This just started today for no apparent reason. I turned the iPad off, waited 30 seconds and turned it back on. As soon as it was finished starting up, the same music glitch began again immediately. I'm using iOS 6.1.3.
Well, no one seems to have any answers or ideas for me, I'll update what I've been able to accomplish.
I reloaded all 14 disks in the time frame of watching Lord of the Rings on Fri. nite.
Funny thing is, the first disk pulled the info from the online store! Hooray!
Wait-then all the next 13 could find no information online...what the heck is up with that? So I MANUALLY assign each disk a new track # to co-inside with each disk, spent about 2 hours doing that.
But still, itunes tells me my playlist is too large, there's not enough space on the ipod. so I unchecked 1 1/2 disks (I'd listen to 1/2 of disk 1 previously) and voila! there's my ipod full of my book. Finally. But what a lot of bother just to keep things in order! -
I purchased a Slingbox HD and purchased the app for my iPad 2. I am wondering if I can load the app on my old iPad without having to pay $30 again?
Where did you download the app from?
I can't find it at the iTunes app store. If you downloaded the app directly from the app developer's site, you need to contact them. -
I purchased the 30 day subscription of Adobe Pro for my Mac Air and downloaded the app and opened it as instructed. Nothing appears to happen after that and I have been unable to use Adobe Pro thus far.
I previously downloaded a trial version of Adobe Pro and had used it the last 30 days. Today I just clicked on the link from my purchase confirmation and downloaded some type of installer. Once I clicked on the installer and gave it permission to do whatever it needed to do, it just sort of stalled. I am running Mac OS Yosemite. I thought Yosemitie might be part of the problem because it has given me occasional problems with Word and some other programs.
-
My hard drive crashed and nothing recoverable, local Apple Store installed a new drive. How can I go back and download the apps I had purchased for my previous configuration, for instance Lion 10.7, and Photoshop Elements 10?
A blank drive needs to be formatted first, you do that hold c boot (or hold option key boot) from the 10.6 install disk (or Lion USB)
Read how to format the drive in Disk Utility here
https://discussions.apple.com/docs/DOC-3044
How to install OS X
https://discussions.apple.com/docs/DOC-3251
Software Update fully,
Hold the option key and click on Purchases when in MAS to download your 10.7 etc. -
I am having problems to run logic pro 9, there is an error display that says I need to set bonjour and that this app serial number has been used by another red user, could anybody guide me? actually, my computer can't start since three days ago, could it be the same problem?
Logic is the APPlication (program, app) that you are having the problem with.
Logic Pro can take advantage of other computers on your local (home or work) network to help it do "heavy lifting" data chores by using Bonjour and a feature called Nodes. It seems that Logic is attempting to find and connect to another machine on your network.
Do you have Logic installed on another computer there? That may be the source of the confilict.
You might want to post this question in the Logic Pro Community.
Be sure to indicate the version of Logic Pro that you are using. I'm sure the folks there can help you out. -
i recently bought the macbook pro 15 inch retina display early 2013? should I return it and get the late 2013 model?
You have 14 days exchange
New retina has which yours doesn't -
802ac wifi, very very fast
Haswell cool running processor
Longer batt life
Lightweight form factor
Faster PCIe SSD
Overall a better machine to have yes
Your choice is subjective to your needs however
peace
Maybe you are looking for
-
Imovie won't open my imovie project
Hello, I was working on an imovie project when imovie kept crashing. So i backed up deleted imovie and reinstalled. Now it won't open up my .rcproject file. Nothing happens. is all my work lost? Also, when it was crashing some of my viedo clips were
-
Update to Acrobat 9.5.1 breaks Flash functionality for reading archived emails
On installing update 9.5.1 to Acrobat Pro on WinXP, I can no longer read the index of previously archived email collections created using the Email to PDF macro in Outlook 2007. The PDF data file indices were readable before, and are still readable i
-
Nomad Jukebox Zen Xtra PLEASE HE
My player was locked on the EAX screen, and I figured out how to get to the rescue mode, and I clicked "Clean Up" and then pressed the check, and then it went back to the rescue mode screen and nothing's happening. Where do I go from here? What does
-
Designer BC4J Generator Extension creates wrong order by clause
Hi, Just tried out the new Designer BC4J Generator Extension and it creates a wrong order by clause. I have a List of values in Designer with one table usage. There is a bound item based on a columnname CODE and has the name L_CODE. The order by sequ
-
Hello Friends, I've generated a simple evDRE report. To my surprise, the Col Keys and Row Keys are not getting hidden, if I hardcode the Keys using some formulae....( for example: using evTIM function for Col header). If i dont hardcode, the keys are