0

I am working on a Travel related website and here is my high level architecture:

ASP.NET MVC 2 (Presentation Layer) 
Services Layer 
Repository Layer communicating with external J2EE Services

For a particular user search scenario, I need to call the J2EE service 4 to 5 times (independent operations), consolidate all responses into a single response and hand it over to the Controller to be able to present it to user.

What is the best way to handle this scenario? Should I use AsyncController feature of MVC 2 or implement some multi-threading logic in my Service layer?

Alex
  • 833
  • 3
  • 15
  • 28

1 Answers1

0

Use Async controller

When should one use asynchronous controller in asp.net mvc 2?

Community
  • 1
  • 1
Xaqron
  • 29,931
  • 42
  • 140
  • 205
  • Thanks Xaqron. Currently my Business Service Layer supports ONLY Synchronous operations. What's required to convert it to support Asynchronous operations? I don't have any control over the J2EE service and I hope no changes would be required in that layer. – Alex Apr 22 '11 at 20:50
  • You don't need anything to do with your BLL. Your MVC code should be async. – Xaqron Apr 23 '11 at 20:24
  • But most of the documentation I read online says that BLL that exposes methods need to implement an event-based asynchronous pattern. Pls. see following link: http://msdn.microsoft.com/en-us/library/ee728598.aspx#converting_synchronous_action_methods_to_asynchronous_action_methods – Alex Apr 24 '11 at 16:44
  • There's nothing wrong or right with design, it's more of what's the best practice. Depending on the case, you may do something which is not good for any other case. You mentioned, you don't have access to BLL and I said that's OK, implement async at the top layer. – Xaqron Apr 24 '11 at 17:21
  • Xaqron, currently I call my BLL method like this inside my Controller:: `PricingResponse response = _pricingService.GetComponentPricing(request); ` Can I continue to call it same way in GetRatesAsync() Action after I change my controller to Async? And then AsyncManager.Parameters["response"] = response; Would that work? – Alex Apr 25 '11 at 07:06