Friday, January 17, 2014

Service Mix 4.0 Overview

Defination of serviveMix in simple words: 
Service Mix is a Container which have a collection of webservices and routing components.

Srandard definition :  
  • Service Mix is a Enterprise Class ,Open Source, Light weight,Distributed Esb and SOA architecture Tool kit
  • We can compare the Service Mix with a computer Mother board having all small components to plug and play.
  • Main Components are : Karaf ,JBI,ESB,ACTIVE MQ,OSGI,JMS,SPRING……etc.
Main Services Provided By Service Mix:

1.JMS Integration   :   Active MQ
2.WebServices       :   JBI and NMR
3.Routing Engine   :   CAMEL, CFX and EIP’s

Service Mix fully supports of:
  •   OSGI Framework
  •        Embeded Spring Framework
We can use service Mix in:
  •   Java Standard Edition
  •   Java J2EE Edition
Service Mix uses ActiveMQ to Provide:
  •   Remoting  
  •    Clustring
  •    Reliability
  •    Distributed Failover
Difference B/w ServiceMix3.0 and 4.x


Directory structure Of Service Mix:

The directory layout of a Karaf installation is as follows:
·         /bin: startup scripts
·         /etc: configuration files
·         /data: working directory
o    /cache: OSGi framework bundle cache
o    /generated-bundles: temporary folder used by the deployer
o    /log: log files
·         /deploy: hot deploy directory
·         /instances: directory containing child instances
·         /lib: contains the bootstrap libraries
o    /lib/ext: directory for JRE extensions
o    /lib/endorsed :directory for endorsed libraries
·         /system: OSGi bundles repository, laid out as a Maven 2 repository
ESB (Enterprise Service Bus)
An ESB is act as a backbone between two similar or different components through which the services flows Like :messaging , routing, transformig and Webservices


Minimum requirements of ESB message delivery
The minimum requirements of an ESB, as a message delivery system, are often referred to by the acronym TRANS,which defines an ESB as a software entity that does the following:


•Transforms messages from one format to another to accommodate the requirements of registered service providers
•Routes messages to registered services while providing quality-of-service and service-level features.
•Augments message content with information, such as additional metadata, about the message requester. Augments the message protocol to meet service provider requirements.
•Notifies registered message listeners about specific message requests.
•Secures delivery of messages by enforcing authentication, authorization, nonrepudiation, confidentiality, etc.

   
    


OSGi overview(OSGi bundle)
  • OSGI: Open Source Gateway Initiative:
  • It is also known as a dynamic module for java,
  • We can deploy the bundles at runtime without bring down the components
  • We can break our application into different parts or modules to reduce the dependencies.
  • Technically OSGi bundles are .jar files with additional meta information.  Osgi is basically used for Implementation and Deployments (Dev side only)
  • Meta information is stored in the META-INF/MANIFEST.MF file.
Difference between  jarfiles and bundles
  • There is basically no difference between jar and bundles
  • Jarfiles contains invisible Javaclasses and libraries files i.e, they are private to other bundles.
  • The manifest file requires OSGi metadata in its manifest so that an OSGi framework can manage the visibility of classes between bundles
  • The key difference with OSGi is that a JAR is now all private, adding metadata in the manifest makes it a bundle that can safely share with other bundles.
  • The Import-Package manifest header tells what packages should be made visible to the bundle, and the Export-Package defines the packages in the bundle that should be made visible to others. Other headers provide additional features.

Bundle-SymbolicName and Version

The name starts by convention with the reverse domain name of the bundle author, e.g. if you own the "example.com" domain then the symbolic name would start with "com.example".
The Bundle-Version and the Bundle-SymbolicName uniquely identifies a bundle in OSGi.
Both properties are defined in the META-INF/MANIFEST.MF file. 


Bundle-LifeCycle:

With the installation of a bundle in the OSGi runtime the bundle is persisted in a local bundle cache. The OSGi runtime then tries to resolve all dependencies of the bundle.
If all required dependencies are resolved, the bundle is in the RESOLVED status otherwise it is in theINSTALLED status
   If the bundle is started, its status is STARTING. Afterwards it gets the ACTIVE status

    


      JBI Overview ( Java Business Integration)


      JBI provides an environment into which components can be plugged in. In this environment, the components collaborate by exchanging information in order to accomplish some tasks. The information is exchanged using a message exchange model according to the web service description language (WSDL) 2.0 or 1.1.


           


      NMR(Normalised Messaging Routing)
   
      The key concept that stands behind JBI is that the components don't exchange messages directly but instead use an internal component that is part of the JBI environment called Normalized Message Router or simply NMR.


    
       A normalized message is built by three different  parts:

  •     The Bare Message: An XML document following the WDSL abstract  message specification
  •     The Metadata: Extra data associated to the message used by the JBI environment to route messages
  •     The Attachments
      

    Service assemblies (SAs) and service units (SUs)

     Service Unit: is a normal JAR file which consists of a configuration file, for ServiceMix this is a XBean configuration and optionally classes and libaries. A service unit is always configured for one service engine or binding component.
S   o we have separate service units for JMS, File and routing configurations. Therefore we need a service assembly,

    Service Assembly:that consists of all the service units (JAR files) for one integration solution. A service assembly is JAR file consisting of a jbi.xml configuration file and the service unit JARs. An example of a XBean configuration for a JMS binding component is:
         
       



     In simple words
     Service Unit is a normal jarfiles which consisting of xmlfiles under METAINF dir and these jar files having dependencies
      service Assembly: it contains one service unit and one extra XML file  depending upon the project
      If it is bean then jbi.xl
      If it is maven the it is pom.xml
    
    Camel Overview

     Camel: It allows XML and Java scala-DSL-based format to express our routes there are all over 70 optional components for expressing routing
     Deployment and installing additional components                                       
     Deployment Routes in {plain blue print.xml, Plain spring XML file}
     Deployment Routes in {OSGIBundle containing plain blueprint.xml and OSGIbundles containing plain spring.XML files}  
   
           


  

     1. There are two Message Endpoints  one for FTP connectivity and another for HTTP.
     2. Messages from these endpoints are fed into the incomingOrderQueue Message Channel
     3. The messages are consumed from the incomingOrderQueue and routed by a Content-   Based Router to one of two Message Translators.
      
      As the EIP name implies, the routing destination depends on the content of the message. 
      In this case we need to route based on whether the content is a CSV or XML   file.
     4. Both Message Translators convert the message content into a POJO, which is fed into the orderQueue Message Channel.
      The whole section that uses a Content-Based Router and several Message Translators is referred to as a Normalizer.
       
      This composite pattern has a unique graphic to depict it but was left out here in favor of its sub-patterns to make things clearer.

     Route Example : Content-Based Router


       

   Enterprise Integration Patterns


          


       Architecture of ServiceMix:

  
       Service mix is basically divided into two main layer
    1. Technology layer---jmx, camel,spring,jbi  
    2. Core layer---logging,
    
     A) The CoreLayer : A lightweight runtime named “Karaf”, which extendsOSGi with powerful features for handling and managing OSGI bundles
•   B) The Technology Layer : A layer of component technologies that sits on top of the core to support your applications 
    
    Overview on  Log4j.properties File:
     Log4j will be usually configured using a properties file or xml file externally. So once the log statements are in place you can easily control them using the external configuration file without modifying the source code. Now let's see how you can obtain the same log output as the previous example using the properties file configuration.
      Three main components you need to configure to obtain the same result are the logger, appender and layout. The logger object is the one that is used to log messages, appender is the one that specifies the output destination like console or a file and layout is the one that specify the format in which the log messages should be logged. 
      When you configure using the BasicConfigurator.configure() method by default it uses theConsoleAppender and PatternLayout for all the loggers.
     Since the rootLogger level is set to DEBUG all the messages are displayed.
     The log4j levels follow the following order.

  •     DEBUG
  •     INFO
  •     WARN
  •     ERROR
  •     FATAL
  •     EXCEPTION


      If you set the rootLogger level to WARN then only the WARN, ERROR and FATAL level log messages will be displayed and the rest will be dropped


                                                      MAVEN:
   What is Maven and how do I install it?
      Maven is the use of repositories to manage jarW files across different projects. In the Maven system, jar files are stored in remote repositories, and they are downloaded to your local machine to a local repository as needed. Typically, these same jar files are accessed across projects, and Maven makes it very simple to manage different versions of jar files, and to group together sets of related jar files. Building different types of projects (such as jars, wars, and ears) is handled very cleanly by Maven. Maven can perform tasks such as generate useful documentation about your project.
      To set up Maven, you need to:
  1.     Download Maven and unzip it
  2.     Create a JAVA_HOME System Variable
  3.     Create an M2_HOME System Variable
  4.     Add %JAVA_HOME%\bin;%M2_HOME%\bin; to your System Path
    To begin with, download the latest Maven from http://maven.apache.org/download.html. I downloaded apache-maven-3.1.1-bin.zip and extracted it to C:\dev\apache-maven-3.1.1



    More Details  about Maven will be Discussed in Next Upcomming Blog.........    




     
  Thanks!!!