• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

WebSphere Asynch Beans

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!