SOA example application

SOA describes a set of patterns for creating loosely coupled, standards-based business-aligned services that, because of the separation of concerns between description, implementation, and binding, provide a new level of flexibility.

Service Oriented Architecture terminology has spread in recent years, at least among people who were involved in most of the Information Technology activities. The guidelines suggested by this methodology are granted as major factors to succeed in different distributable systems domains.
Just as the definition is clear and easy to understand, so is its implementation into a real project, being intuitive, concise and elegant.

I have released an application demonstrating how SOA’s principles can be applied into a small project making use of EIP (Enterprise Integration Pattern), IoC (Inversion of Control), and a building tool and scripting language such as Groovy.
I analized a simple business case: an entertainment provider who wanted to dispatch rewards and bonuses to some of its customers, depending on customer service’s subscriptions.
The process sequence is simple:

It is required to provide an implementation of a RewardsService. The service accepts as input a customer account number and a portfolio containing channels subscriptions. The Customer Status team is currently developing the EligibilityService which accepts the account number as an input.

I set up an infrastructure to write acceptance tests for this first meaningful feature. This is what could be defined as a “walking skeleton,” a prototype with the essential aspect that it could be built, deployed and tested after being easily downloaded from Github.

RewardService is invoked by the client and it calls, in turn, the eligibility service which however, in this case is not  implemented. As many real scenarios expect external services, this proof-of-concept refers the eligibility service to a black-box, where only request/response interface is known.

The unit test simulates the eligibility service behaviors mocking the end-point through the Camel Testing Framework. However, if you want to run the application on your local machine I set up, within a line of code, a faux eligibility service that merely returns a positive response:

def alwaysEligible = {exchange -> if(exchange){exchange.getOut().setBody('CUSTOMER_ELIGIBLE')}} as Processor

The entry point is an HTTP Restful interface built upon the Apache CXF, and is easily set up within few lines in the configuration. CXF is initialized by Spring in this following way:

jaxrs.'server'(id:'restService',address:'http://${http.host}:${http.port}') {jaxrs.'serviceBeans'{ ref(bean:'rewardService')} }

Services are connected by Apache Camel. RewardService contains only the reference of the ESB context –  an instance of ProducerTemplate. Such solution allows a complete separation between the linking system and the business services. The Camel context represents  the SOA’s wiring, and is configured through a DSL as in the example below:

from('direct:rewards').to(eligibilityServiceEndpoint)
About these ads

2 thoughts on “SOA example application

  1. I just wonder how transaction are implemented (or realized) in SOA based application. As far as I know it used to build with service compensation but this will lead to an increase of difficulty to build an highly concurrent application.

    • Am guessing this is a really late reply! Neverthless… I am assuming that you are looking for transaction boundaries. These are often implementation specific – as in the Java based SOA/ESB implementations support JTA over the existing transports. You can establish transaction boundaries like you would do in a regular Java based application.

      For instance if you had a route such as:
      from(“activemq:queue:foo”).policy(requirenew).to(“activemq:queue:bar”);

      You can define transaction policy and use them

      More details at: http://camel.apache.org/transactional-client.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
The Esquire Theme.

%d bloggers like this: