• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

WebSphere Asynch Beans

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've three threads. T1 is main thread and T2 is the child thread. I've to perform a task on Thread T2 in both Synchronous as well as Asynchronous manner by using an explicit call from Thread T1. For Async call, I'm using my code as below.

Context ctx = null;
ctx = new InitialContext();
WorkManager wm = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_JNDI_NAME);
WorkManager slaveWM = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_SLAVE_JNDI_NAME);
AValhallaAsyncMgr asyncMgr = new AsyncRatesBookingRequestHandler(slaveWM, req.getRequestContextBean());
wm.startWork(asyncMgr); //Async Validation

The above code snippet is working good. But for Synchronous call, I need to initiate the child thread T2 from main thread T1 and I should execute it asynchronusly without affecting T1 performance and join the response to parent thread T1. Currently I'm using the code snippet as like below.

Context ctx = null;
ctx = new InitialContext();
WorkManager wm = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_JNDI_NAME);
WorkManager slaveWM = (WorkManager)ctx.lookup(RatesConstant.WORK_MANAGER_SLAVE_JNDI_NAME);
AValhallaAsyncMgr asyncMgr = new AsyncRatesBookingRequestHandler(slaveWM, req.getRequestContextBean(),req,respBo,logOrFail,new RatesWorkStatusHandler());
wm.doWork(asyncMgr); //Sync Validation

The problem here is, when doWork() is being called, T1 is continuing with its execution, without being waited for T2 to finish of its execution. I can allow only 200ms for T2 to execute, means I can allow T1 to wait for only 200ms. If T2 exceeds this time, T1 is not getting the update from T2. How can I achieve this???

Thanks,
Gayathri
 
You have to be odd to be #1 - Seuss. An odd little ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic