Reference cards (cheat sheets) collection.

Every architecture is formed based on certain design principles and Microservices is no different. This article will not talk about what Microservices is all about. There are already plenty of articles and blogs to do that. In this article, I will talk about what it takes to devise a Microservices based architecture. We will take a look at some of the design principles one should take into account to design a Microservices based applications.

Isolation

Services must be designed to work in isolation. When you break up a monolithic system into set of services, it is necessary that these services are decoupled from one another, are made more cohesive and self sufficient. Each service should be able to handle its failure without breaking the whole application or system. Isolating and decoupling enables service to recover itself from the failure condition very quickly. The isolation characteristic of the service has the following benefits: easy adoption of continuous delivery, better scaling, effective monitoring and testability.

Autonomous

Isolation paves the way for autonomy. Services must be designed to be autonomous. It must be cohesive and able to fulfill its function independently. Every service can be independently invoked using a well defined API (URI). The API in a way identifies the service function. Autonomous service must also deal with its own data. More popular term is polyglot persistence where each service has its own persistence store. Autonomy also ensures resiliency. An autonomous service has the following benefits: Effective service orchestration and coordination, better scaling, communication through well defined API, faster and controlled deployment.

Single Responsibility

Service must be designed to be highly cohesive. A single responsibility principle is where the service performs only one important function. The single responsibility aspect gels well with the term ‘micro’. Micro indeed means small, fine grained and only relevant within its scope of responsibility. The single responsibility feature has the following benefits: Services composition is seamless, better scaling, reusability, extensibility and maintainability.

Bounded Context

How big or small your services should be? Million dollar question? Well the answer lies in what is called as Bounded Context design principal. It is a key pattern while devising a Domain Driven Design (DDD) modeling approach. Bounded context is all about defining a context in which your Microservices will be providing its services. It is about evaluating your domain model and identifying discrete boundaries and accordingly designing your Microservices to make it more cohesive and autonomous. That also means communication across boundaries becomes more efficient and your service in one bounded context need not be dependent on service in another bounded context for too many things.

Asynchronous Communication

While drawing discrete boundaries and designing services with its own bounded context, it is necessary that service communication across boundaries must be asynchronous. The asynchronous mode of communication naturally leads to loose coupling between services and allows for better scaling. With synchronous communication, you are blocking a call and waiting for the response. A service in a blocking state cannot perform another task until the response is received and the underlying thread is released. It leads to network congestion and impacts both latency and throughput. Asynchronous communication can also bring in the notion of implementing a well defined integration or communication pattern to achieve a logical workflow involving different services.

Location Independent

Microservices, by design, are good candidates to be deployed in a virtualized environment or docker containers. With the advent of cloud computing, we can have plethora of service instances that can take advantage of dynamic scaling environment. The services could be running on multiple nodes across small or large clusters. Services itself can be relocated depending upon the availability or efficiency of the underlying computing resource. One must be able to address or locate the service in a location independent manner. Often different lookup discovery patterns can be used to consume your service. The client or consumer of the service does not have to bother about where a particular service is deployed or configured. It just uses some kind of logical or virtual address to locate the service.

Microservices is not a technology, framework or a solution. It is an architectural style that provides you an approach or methodology to deal with the complex nature of a monolithic application. The approach starts with the above design principles that you can use to architect Microservices based application.

Reference cards (cheat sheets) collection.

The WebLogic Server 12c has very nice support for Maven now.

The doc for this is kinda hidden though, so here is a direct link http://docs.oracle.com/middleware/1212/core/MAVEN To summarize the doc, Oracle did not provide a public Maven repository manager hosting for their server artifacts. However they do now provide a tool for you to create and populate your own. You can setup either your local repository (if you are working mostly on your own in a single computer), or you may deploy them into your own internal Maven repository manager such as Archiva or Nexus.

Here I would show how the local repository is done. First step is use a maven plugin provided by WLS to populate the repository. I am using a MacOSX for this demo and my WLS is installed in $HOME/apps/wls12120. If you are on Windows, you may install it under C:/apps/wls12120.

1
2
3
$ cd $HOME/apps/wls12120/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.2/
$ mvn install:install-file -DpomFile=oracle-maven-sync.12.1.2.pom -Dfile=oracle-maven-sync.12.1.2.jar
$ mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=$HOME/apps/wls12120 -Doracle-maven-sync.testingOnly=false

The artifacts are placed under your local $HOME/.m2/repository/com/oracle. Now you may use Maven to build Java EE application with these WebLogic artifact as dependencies. Not only these are available, the push also populated some additional maven plugins that helps development more easy. For example, you can generate a template project using their archetype plugin.

1
2
3
4
5
6
7
8
$ cd $HOME
$ mvn archetype:generate \
-DarchetypeGroupId=com.oracle.weblogic.archetype \
-DarchetypeArtifactId=basic-webapp \
-DarchetypeVersion=12.1.2-0-0 \
-DgroupId=org.mycompany \
-DartifactId=my-basic-webapp-project \
-Dversion=1.0-SNAPSHOT

Type ‘Y’ to confirm to finish. Notice that pom.xml it generated; it is using the “javax:javaee-web-api:6.0:provided” dependency. This is working because we setup the repository earlier. Now you may build it

1
2
$ cd my-basic-webapp-project
$ mvn package

After this build you should have the war file under the target directory. You may manually copy and deploy this into your WebLogic server domain. Or you may continue to configure the maven pom to do this all with maven. Here is how I do it. Edit the my-basic-webapp-project/pom.xml file and replace the weblogic-maven-plugin plugin like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<plugin>
       <groupId>com.oracle.weblogic</groupId>
       <artifactId>weblogic-maven-plugin</artifactId>
       <version>12.1.2-0-0</version>
       <configuration>
         <middlewareHome>${oracleMiddlewareHome}</middlewareHome>
         <adminurl>${oracleServerUrl}</adminurl>
         <user>${oracleUsername}</user>
         <password>${oraclePassword}</password>
         <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
         <targets>${oracleServerName}</targets>
         <verbose>true</verbose>
         <name>${project.build.finalName}</name>
       </configuration>
     </plugin>

With this change, you may deploy the webapp into WebLogic server (well, assuming you already started your “mydomain” with “myserver” server running locally. See my previous blog for instructions)

1
2
$ cd my-basic-webapp-project
$ mvn weblogic:deploy -DoracleMiddlewareHome=$HOME/apps/wls12120 -DoracleServerName=myserver -DoracleUsername=admin -DoraclePassword=admin123

After the “BUILD SUCCESS” message, you may visit the http://localhost:7001/basicWebapp URL.
Revisit the WLS doc again and you will find that they also provide other project templates (Maven calls these archetypes) for building EJB, MDB, or WebService projects. These should help you get your EE projects started quickly.

The term ‘java developer’ covers a wide range of individuals. It starts with fresh graduates looking for jobs and goes up till experienced Java Enterprise Edition developers. There are a wide range of concepts and skills that Java developers must posses in order to be important in the industry. It is highly advisable to know the language fundamentals thoroughly, rather than specific frameworks or syntax. The following websites will offer professional Java developers a storehouse of valuable information as also a platform to interact and prosper!

1.DZone - DZone

Place where community members discover and share the latest and most popular news from around the web. This community-driven page is carefully moderated by an expert editorial staff to ensure the content remains interesting and relevant.

2.LeetCode - LeetCode

LeetCode is a social platform for preparing IT technical interviews. The website provides code solution using the Online Judge system, high quality article featuring in-depth thought process and more.

3.Stackoverflow - Stackoverflow

Stack Overflow is a question and answer site for professional and enthusiast programmers. It’s 100 per cent free, no registration required.

4.Java SE Technical Documentation - Java SE Technical Documentation

Contains all documents you will need to use API of Java SE. It’s a one-stop shop for everything recent in the world of Java and it’s Oracle’s official website, so all the material here is 100 per cent geniune and update very frequently.

5.Coursera - Coursera

Coursera is an education platform that partners with top universities and organisations worldwide, to offer courses online for anyone to take, for free.

6.Java World - Java World

JavaWorld is the leading independent resource for enterprise Java technology developers, architects, and managers who want to learn more about Java and related technologies from professional developers and trusted industry experts. JavaWorld reaches the core audience of IT professionals who are planning, developing, deploying, and integrating Java-based solutions on an enterprise level.

7.Github - Github

Apart from hosting your projects for free, Github is also an excellent resource for learning popular Java libraries and frameworks with corresponding examples.

8.Program Creek - Program Creek

The website contains some very interesting articles written by people from different areas. The articles here are supported by relevant diagrams and code examples.

9.Wikipedia - Wikipedia

Our discussion will be far from over without the mention of this particular website that has been a store house of immense resources on practically any topic out there. You may just want to know some concept, but not learn much and the website will do you loads of good. Frequently updated information is available for free.