locked
Event driven or Request-Response SOA - a practical application RRS feed

  • Question

  • Hi,

     

    After reading 10 articles over the last couple of days, I need some practical input about how to define service communication in SOA - just a general example would be great.

     

    For example, consider a Car rental company that has these two services.
    For all methods it must be possible to consume using ordinary soap clients and CreateCarReservation must create a customer using CreateCustomer.

    • Car service: GetCarList, CreateCarReservation
    • Customer service: CreateCustomer
     
    I wonder how you would define the communication here? I'm thinking practical example, what async events, sync resquest/responses do you see?
     
    --
    Monday, December 8, 2008 1:26 PM

Answers

  •  Werner Clausen wrote:
     GajaKannan wrote:

    GetCarList  is consumed synchronously by the consumer facing application.  It is also called asynchronously by third party aggregators/resellers like Orbitz, priceline that stores the latest update from the public message queue subscription and present it to their users as they see fit.

     

    So you would say that GetCarList must publish some event when a list is ready? So that this service actually contains 2 ways of delivering the list: Sync response xml to GetCarList and async event with the same response xml)?

    Yes

     Werner Clausen wrote:

    And In your opinion, would this logic be valid for all service methods that reside in public environments?

    Not all the service that resides in the public environments need to be in this format.  There could be some that provide realtime/synchronous access.  This is one example from the list you provided fits into pub/sub model

     Werner Clausen wrote:

    And last how would the event that delivers the list be triggered - only from some "GetCarListAsync"?

    Your server publishes the new GetCarList items based on what you think is the best option and your requirements.  Like every night 10 pm or every 2 hours from 6 am-10 pm etc.,  I can not tell what would be the best interval.  Your consumers would subscribe to this event and persist in a physical datastore or cachestore based on what works best for them.

     

    Tuesday, December 16, 2008 3:12 AM
  • I'd suggest implementing this fairly simply with regular HTTP and XML.

     

    Your subscribers go to a web page on your site after logging in and provide the URL where they want the data pushed. You save that URL somewhere (DB). You also provide them with the XML schema of the messages you'll be sending them.

     

    You can use nServiceBus and MSMQ for most of your system, just have one subscriber to your publisher that goes to the DB, takes out all the URLs, and pushes the XML messages it receives to those endpoints.

     

    Hope that helps.

    Thursday, January 22, 2009 3:23 PM

All replies

  • You could start out by creating request and response message for your service calls.

    GetCarList

    Input XML Request- Car Type, Occupancy, etc.,

    Output XML Request- Available Dates, Daily Rate, Weekly Rate, Monthly Rate, etc.,

    CreateCarReservation

    Input XML Request- Customer Info, Credit Card, Rental dates, etc.,

    Output XML Request- Available Dates, Total Rate, pickup aisle, etc.,

    As you mentioned CreateCustomer is an encapsulated activity within CreateCarReservation.

    Now, CreateCarReservation service would be consumed synchronously a calle application at rental kiosk or website by end customer.

    GetCarList  is consumed synchronously by the consumer facing application.  It is also called asynchronously by third party aggregators/resellers like Orbitz, priceline that stores the latest update from the public message queue subscription and present it to their users as they see fit.

     

    Monday, December 8, 2008 5:52 PM
  • Werner,

     

    In your example, the Rental service would publish a ReservationMade event containing the type of car, person's driver license number, phone number, etc.

     

    The Customer Care service would subscribe to that event, and when received, would check if that driver license number was already on file, and if not, create a customer record containing the relevant information from the event, finally publishing its own CustomerCreated event.

     

    How does that sound?

     

    I have another example of the connection between EDA and SOA up on my blog here:

     

    SOA, EDA, and CEP a winning combo

     

    Hope that helps.

     

    Monday, December 8, 2008 6:50 PM
  •  GajaKannan wrote:

    GetCarList  is consumed synchronously by the consumer facing application.  It is also called asynchronously by third party aggregators/resellers like Orbitz, priceline that stores the latest update from the public message queue subscription and present it to their users as they see fit.

     

    So you would say that GetCarList must publish some event when a list is ready? So that this service actually contains 2 ways of delivering the list: Sync response xml to GetCarList and async event with the same response xml)?

    And In your opinion, would this logic be valid for all service methods that reside in public environments?

    And last how would the event that delivers the list be triggered - only from some "GetCarListAsync"?

     

    Thanks.

     

    --

    Tuesday, December 9, 2008 10:57 AM
  •  Udi Dahan The Software Simplist wrote:

    In your example, the Rental service would publish a ReservationMade event containing the type of car, person's driver license number, phone number, etc.

     

    The Customer Care service would subscribe to that event, and when received, would check if that driver license number was already on file, and if not, create a customer record containing the relevant information from the event, finally publishing its own CustomerCreated event.

     

    How does that sound?

     

    I have another example of the connection between EDA and SOA up on my blog here:

     

    SOA, EDA, and CEP a winning combo

     

    Hope that helps.

     

     

    Hi Udi, this sounds very good. And I just find out that you are the guy behind the articles I have bookmarked Smile - really nice work btw I have already read that article a couple of times before this post.

     

    I am really hooked on this Publish/Subscr. structure as it will solve many of my main concerns about a vast structure and the more I read about it the more clear it becomes to me that this is what I'm after. However I'm still missing some key practices on how to communicate:

     

    A)

    With third party consumers. For example a booking site that uses "GetCarList". How does he connect? I cannot see how he/they can hook into a message queue in some cross-platform, standard way. So I guess he would connect using a sync Request/Response. This would also mean that there are 2 ways to get the Carlist: The first is "GetCarListAsync" which replies in the event "CarListGenerated" and the second is the "GetCarList" which returns the sync response. Do you agree on this?

     

    B)

    Should all responses - even (large) lists like "GetCarList" be published and accessible within the Event data? Personally I dont have any problem with this, however some articles seem to suggest that this could be bad design - but it might just be from a technical p.o.v.

     

    C)

    Should all methods have both sync. and async ways of communicating? Or would best practice be to just create Sync messages for those "public" services? (however the definition of a "public" service is not yet clear to me).

     

    Thanks for your time...

     

    --

     

     

     

    Tuesday, December 9, 2008 11:43 AM
  • Public consumers are best served by REST-like protocols:

    See the REST-ful Polling section of my post Scaling Long-Running Web Services.

    In other words, GetCarList wouldn't exist as a "webmethod", but rather as a resource similar to:

    http://www.AcmeCars.com/CarList/current/

    When you're list of cars changes, you'd update this resource - a static file.
    Consumers would simply HTTP GET this URL.

    You could also use all sorts of HTTP headers to control the caching behavior for further performance gains.

    Does that make sense?

    Wednesday, December 10, 2008 1:21 PM
  • Hi Udi,

     

    Well, yes it makes sense in terms of looking at data that may be "long" time in process. However to see this as a means of having async delivery to consumers doesnt seem "intuitive" - I like it, but it just doesnt feel right. Especially when talking about high performance services (deliver response with 100-300 ms) it would seem to be the wrong path having the consumer poll the results. Unless you want him to poll every 100ms (which is even more wrong). 

     

    You might compare this "GetCarList" example to availability functionality in airline or hotel services. So, for non C-U-D operations we are talking high performance services that are consumed by other websites reacting to customers searching for cars (with inputs like date, cartypes, etc). And it seems that the Asynchronous Completion Token pattern idea is somewhat targeted some other problem (where performance isnt top priority).

     

    In any case, to me, it would make more sense to register some "message notification uri" with each request, so that a message bus can push the response (or just notify that the data is available) to the correct consumer and method. But then it cant be serviced from applications like a browser (but this was never my case anyway). But this would probably call for some other patterns that I have yet to see...

     

    In the case that I'm not completely missing the point about the async token pattern (in which case I would very much like to be told), do you have a comment on my A, B, C questions from before?

     

    --

     

     

     

     

    Monday, December 15, 2008 9:46 AM
  • I'm beginning to understand your scenario - you're doing server to server integration as opposed to serving this data directly to the users browser. In that case, couldn't these partner web sites subscribe to your notifications about availability changes, cache the data on their end, and then query against their cache?
    Monday, December 15, 2008 1:24 PM
  •  Werner Clausen wrote:
     GajaKannan wrote:

    GetCarList  is consumed synchronously by the consumer facing application.  It is also called asynchronously by third party aggregators/resellers like Orbitz, priceline that stores the latest update from the public message queue subscription and present it to their users as they see fit.

     

    So you would say that GetCarList must publish some event when a list is ready? So that this service actually contains 2 ways of delivering the list: Sync response xml to GetCarList and async event with the same response xml)?

    Yes

     Werner Clausen wrote:

    And In your opinion, would this logic be valid for all service methods that reside in public environments?

    Not all the service that resides in the public environments need to be in this format.  There could be some that provide realtime/synchronous access.  This is one example from the list you provided fits into pub/sub model

     Werner Clausen wrote:

    And last how would the event that delivers the list be triggered - only from some "GetCarListAsync"?

    Your server publishes the new GetCarList items based on what you think is the best option and your requirements.  Like every night 10 pm or every 2 hours from 6 am-10 pm etc.,  I can not tell what would be the best interval.  Your consumers would subscribe to this event and persist in a physical datastore or cachestore based on what works best for them.

     

    Tuesday, December 16, 2008 3:12 AM
  • I've done some work in the travel industry and often the business response to any question of availability is "of course".

     

    When reservations come in, then the issue of demand against supply is balanaced using business rules and conflict resolution protocols.

     

    For instance, for car rentals, when you come to pick up your car, and they don't have the specific car type you requested, they offer you a different car in the same class, maybe giving you some kind of voucher (free dinner or something).

     

    This is often easier to support technically than providing real-time answers to availability questions (that actually may cause the potential customer to not reserve a car).

     

    I know that this may sound like I'm skirting the core technical question, but that's what solutions architecture is about - finding the minimal technical solution with the maximal business return.

     

    Wednesday, December 24, 2008 10:17 PM
  •  Udi Dahan The Software Simplist wrote:
    I'm beginning to understand your scenario - you're doing server to server integration as opposed to serving this data directly to the users browser. In that case, couldn't these partner web sites subscribe to your notifications about availability changes, cache the data on their end, and then query against their cache?

     

    Hi Udi,

     

    Tanks for your post. Sorry about the late, late answer, but I have been away for a little month now, due to some unforeseen and not needed circumstances. Hopefully you still monitor this thread?

     

    You understand my scenario correct. And yes, the solution you descreibe would be the best scenario, however, I need the solution to be 100% platform independent. In theory, MSMQ is following the standard for MQM but in praxis I have the feeling that its somewhat problematic to connect from some PHP for example - because of the lack of tools. I havent investigated this indepth but this is how status is in my head...I must check up on this because it would be nice to be able to use nServiceBus for example.

     

    If MSMQ isnt possible (in praxis) from all platforms, then some simple webservices are. But this leaves me on my own so it seems. I cant find any good examples of how to design a webservice event bus (for lack of better word).

     

    --

     

    Monday, January 12, 2009 9:08 AM
  • I'd suggest implementing this fairly simply with regular HTTP and XML.

     

    Your subscribers go to a web page on your site after logging in and provide the URL where they want the data pushed. You save that URL somewhere (DB). You also provide them with the XML schema of the messages you'll be sending them.

     

    You can use nServiceBus and MSMQ for most of your system, just have one subscriber to your publisher that goes to the DB, takes out all the URLs, and pushes the XML messages it receives to those endpoints.

     

    Hope that helps.

    Thursday, January 22, 2009 3:23 PM
  •  Udi Dahan The Software Simplist wrote:

    I'd suggest implementing this fairly simply with regular HTTP and XML.

     

    Your subscribers go to a web page on your site after logging in and provide the URL where they want the data pushed. You save that URL somewhere (DB). You also provide them with the XML schema of the messages you'll be sending them.

     

    You can use nServiceBus and MSMQ for most of your system, just have one subscriber to your publisher that goes to the DB, takes out all the URLs, and pushes the XML messages it receives to those endpoints.

     

    Hope that helps.

     

    It sure does. I appreciate your time and answers here. Thanks.

     

    Monday, January 26, 2009 9:51 AM