...
Warning | ||
---|---|---|
| ||
|
Prerequisites
- Maven 2.0.7 or higher
- If you have never used Maven previously the Maven Getting Started Guide explains some valuable concepts surrounding Maven
- ServiceMix 3.2.1 or higher
- A broadband internet connection so Maven can automatically download dependencies
General
This tutorial will explain to you how to write your own binding components. What you learn here is also enabling you to write own service engines because the difference between a binding component and a service engine is of pure logical nature. While a binding component is translating data from outside bus to normalized messages used inside the bus and vice versa a service engine is only working inside the bus with normalized messages.
Should I really create my own binding component?
Before beginning this tutorial, please take the time to read the FAQ entry titled "Should I Create My Own JBI Components?". It is very important that you understand the reason for developing a JBI binding component and this FAQ entry will explain this to you.
A very brief introduction to Java Business Integration (JBI)
The Java Business Integration (JBI) spec provides a standards-based, service-oriented approach to application integration through the use of an abstract messaging model, without reference to a particular protocol or wire encoding. JBI introduces the concepts of Binding Components (BCs), Service Engines (SEs) to Service Units (SUs) and Service Assemblies (SAs) to define an architecture for vendor-neutral pluggable components. The purpose of this architecture is to provide standards-based interoperability amongst components/services.
JBI components can be thought of as the smallest applications or services accessible in a service-oriented architecture. Each service has a very specific purpose and therefore a narrow scope and set of functionality. Components come in two flavors:
- Service Engines (SE)
- Binding Components (BC).
SU*s must be packaged into a *SA to be deployed to the JBI container. A SA is a complete application consisting of one or more services. By comparison, this is similar to the way that WAR files must be packaged inside of an EAR file to be deployed to a J2EE container.
See also the page providing information on working with service units
Below some quick definitions which are dominant throughout the JBI spec:
- Component Architecture
- Binding Components - Components that provide or consume services via some sort of communications protocol or other remoting technology
- Service Engines - Components that supply or consume services locally (within the JBI container)
Note |
---|
The difference between binding components (*BC*s) and service engines (*SE*s) is definitely subtle and is not denoted by the JBI APIs. In fact, the only real true difference between the two is in the |
- Component Packaging
- Service Units - Packaging for an individual service that allows deployment to the JBI container; similar to a WAR file from J2EE
- Service Assemblies - Packaging for groups of *SU*s for deployment to the JBI container; similar to an EAR file from J2EE
This tutorial focuses on both component architecture and component packaging. For further information and details on JBI, see the following:
- The JBI spec
- The JBI section of the User's Guide
- The JBIforSOI article
- The ServiceMix as an enterprise service bus JavaWorld article
Getting started with a BC
This tutorial will explain to you how to create a binding component for the SNMP protocol. If you don't know what this protocol is about, then see for example the http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol Wikipedia entry for further details. As a first step we will only create a snmp polling service. Once you understand how to do this, you will be able to go further and create also a sender service but this will be not done inside this tutorial for now.
Now let's move on to creating the Maven projects for the SNMP binding component.
Creating a Maven project for the JBI BC
The focus of this section is on the creation of a JBI binding component. For this task, a Maven archetype will be used to create a Maven project skeleton to house the component. Maven archetypes are templates for Maven projects that jumpstart project creation via the automation of repetitive tasks by following standard conventions. The result of using an archetype to create a Maven project is a directory structure, a Maven POM file and, depending on the archetype being used, sometimes Java objects and JUnit tests.
Below are the steps to follow for creating the directory structure and project. All instructions are laid out to take place on a Unix command-line.
1) Create a directory named servicemix-snmp
and switch to that directory:
Code Block |
---|
$ mkdir servicemix-snmp-tutorial
$ cd servicemix-snmp-tutorial
|
2. Setup a project Maven configuration file
...
3) Use the servicemix-binding-component Maven archetype to generate a Maven project for the component.
To create a BC, execute the following command on the command-line:
Panel |
---|
$ mvn archetype:create \ |
The command above will create a directory named hello-world-bc
that houses a Maven project for the JBI service engine being created here. The name of the directory is taken from the artifactId
parameter.
Note | ||
---|---|---|
| ||
|
...