About Me
Facebook
Facebook
Linked In
Linked In
Twitter
Twitter
YouTube
YouTube
Google +
Google +
Showing posts with label JBoss Fuse. Show all posts
Showing posts with label JBoss Fuse. Show all posts

August 02, 2015

Developing Hello World Restful Service with Fuse

Introduction:
Fuse ESB Enterprise's embedded Web and RESTful services framework is based on Apache CXF. They provide a small footprint engine for creating reusable web services and for service-enabling new and legacy applications as part of an integration solution.
RESTful Service Development Pattern
Overview
Representational State Transfer (REST) describes a stateless client-server architecture in which web services are treated as resources that can be identified by their URLs.
In RESTful systems, servers use URIs to expose resources, and clients use the four HTTP verbs GET, POST, PUT, and DELETE to access them. As they receive a representation of a resource, client applications enter a state. When they access another resource, typically by following a link, client applications change their state.
Because RESTful systems can take full advantage of HTTP's scalability features, such as caching and proxies, they are highly scalable and highly flexible. Changes made to servers do not impact clients because:
·         Resources are accessed and manipulated using the four HTTP verbs.
·         Resources are exposed using a URI.
·         Resources are represented using standard grammars.
Today's Web architecture is an example of a system designed on RESTful principles. Web browser clients access resources hosted on Web servers. The resources are represented using HTML or XML grammars understood and navigable by all web browsers.
JAX-RS development
Fuse ESB Enterprise supports JAX-RS (JSR-311), the Java API for RESTful Web Services. JAX-RS provides a standard way to build RESTful services in Java, using annotations to simplify the development and deployment of web service clients and endpoints.
Using JAX-RS to develop restful services has several benefits:
·         The URI bindings are local to the resource beans, which can be arbitrarily nested. This feature simplifies refactoring.
·         Loose coupling between providers and the objects returned by the resource methods makes it easy to drop in support for new representations, without having to change the code of the resource beans (or controllers). Instead, you need only modify an annotation.
·         Static typing can be useful when binding URIs and parameters to the controller. For example, using String, integer, and Date fields frees the controller from having to explicitly convert parameter values.
JSON data bindings
 JavaScript Object Notation (JSON), a lightweight data format for data exchange, is provided as an alternative to JAXB. JSON is a text-based and human-readable format for representing simple data structures and associative arrays (called objects).
Implementation:
Suppose you want to create a RESTfull web service using CXF for hello world.  You would typically want to perform following operations.
Ø  Create Fuse Project
Ø  Create Java classes
Ø  Create Camel Context
Ø  Deploy in Fuse Server
Ø  Test Hello world
Create Fuse Project:
Step 1: Go to Fileà New à Fuse Project.
Step 2: Give Project name as ‘FuseHelloWorldRSService’ and click on next.
Step 3: Select the artifact ID: camel-archetype-spring-dm and Group ID: org.apache.camel.archetypes and give the details as shown below and click on finish.
Create Java classes
Step 4: Create  HelloWorldReqest , HelloWorldResponse, HelloWorldImpl and HelloWorldResponseTransformer classes and generate setter and getter methods.
Step 5: Open POM.xml fine and add the following dependencies, so that incase of any errors in our Java classes will resolve these dependencies.
Create Camel Context
Step 6: Open the blueprint.xml under camel Contexts folder. Delete the content on blueprint.xml

Step 7: Click on source to edit the blueprint.xml file and add the schema locations.
Step 8: Add Bean entries for classes and service endpoint to blueprint.xml.
Step 9: Add the routes in blueprint.xml
Deploy in Fuse Server
Step 10: Right click on pom.xml à Run As à Maven Install
Once the build successful we can see the success build message in console.

Step 11: Start Fuse server. Run the below command in Fuse server command prompt.
osgi:install -s mvn:com.eai.helloworldrs/helloworldrs/1.0.0-SNAPSHOT

Run the list command to check the status of the service. You can see below the service is in run status with Bundle ID 273.
Test Hello world
Now our service is running on Fuse server. We need to test now.
Open Mozilla Browser and Install the Rest Client plug-in which is under Mozilla plug-in’s. This plug in is used for test the rest services.
Enter the ‘http://localhost:9090/getHelloWorld/getHelloWorld?name=Ameer’ under url, select as GET method and click on Send. We can see the response under Response Body(Raw) tab as shown below.

Summary:
We have learnt how to develop simple hello world program with restful services with Fuse. I will soon post new post with advance usage/ implementations with restful services in Fuse.
Downlad:
S. No
File Name
Download
1
Developing HelloWorld Restful Service.pdf
2
FuseHelloWorldRSService.zip

continue reading

July 26, 2015

The Red Hat JBoss Fuse Architecture



Introduction

IT system integration is one of the biggest challenges facing modern enterprises. Red Hat JBoss Fuse; one of the modern open source integration platform, using a lightweight standards-based, loosely-coupled approach. By relying on standards, JBoss Fuse reduces the chances of vendor lock-in. By advocating loose coupling, Red Hat JBoss Fuse reduces the complexity of integration.
An ESB is a standards-based integration platform that combines messaging, web services, data transformation, and intelligent routing to reliably connect and coordinate the interaction of significant numbers of diverse applications across extended enterprises with transactional integrity.
An ESB is typically defined by the list of services it provides. Services commonly included are:
  • Transport mediation—not all applications and services that need to be integrated use HTTP or JMS.
  • Dynamic message transformation—not all services use SOAP and are unlikely to require the same message structures.
  • Intelligent routing—not all messages emanating from a source are intended for the same destination. The target destination will likely depend on some criteria inherent in the message.
  • Security—only authorized and authenticated users need have administrative access to the JBoss Fuse runtime; services and brokers that handle sensitive information may restrict access by unauthorized or unauthenticated clients only; similarly, messages that contain sensitive information may be encrypted as they transit their routes.
An ESB simplifies the complexity of integration by providing a single, standards-based infrastructure into which applications can be plugged. Once plugged into the ESB, an application or service has access to all of the infrastructure services provided by the ESB and can access any other applications that are also plugged into the ESB.
Architecture
Red Hat JBoss Fuse has a layered architecture that consists of the following three layer as shown below.

Kernel layer
The Red Hat JBoss Fuse kernel layer is based on Apache Karaf, an OSGi-based runtime that provides a lightweight container into which you can deploy various components and applications.
The kernel layer interacts with the Services layer to set up, coordinate, and manage logging, and security; and to manage transactions on a per service basis. It also interacts with the Service layer to set up message broker instances with the configuration specified in the supplied activemq.xml file.
The kernel layer provides these features:
Console
The Red Hat JBoss Fuse console is a shell environment that enables you to configure all JBoss Fuse components and to control the JBoss Fuse runtime, including brokers and messages, JBoss Fuse kernel instances, logging, and so on.
Logging
A dynamic logging back end supports different APIs (JDK 1.4, JCL, SLF4J, Avalon, Tomcat, OSGi). By default, Red Hat JBoss Fuse enters all log messages in a single log file, but you can change this behavior by configuring different log files to store log messages generated by specific JBoss Fuse components.
Deployment
We can manually deploy applications using the osgi:install and osgi:start commands, or you can automatically deploy them by copying them to the hot deploy folder. When a JAR file, WAR file, OSGi bundle, or FAB file is copied to the InstallDir/deploy folder, it's automatically installed on-the-fly inside the Red Hat JBoss Fuse runtime.
Fuse Application Bundle (FAB)
FABs automate the creation and maintenance of OSGi bundles, freeing application developers to focus on building their applications.
Provisioning
Applications are provisioned through hot deployment, the Maven repository, and remote downloads.
Configuration
The properties files contained in the InstallDir/etc directory are continuously monitored, and changes are automatically propagated to the relevant services at configurable intervals.
Security
The security framework is based on Java Authentication and Authorization Service (JAAS). You can secure separately, Red Hat JBoss Fuse's OSGi container, deployed instances of the embedded messaging service, and deployed instances of the embedded routing and integration service.
OSGi container
We can deploy a variety of packages and files into Red Hat JBoss Fuse's OSGi container including Fuse Application Bundles, OSGi bundles, JARs, WARs, Blueprint, and Spring.
Dependency injection frameworks
The supported dependency-injection frameworks facilitate deploying new OSGi applications and updating existing ones dynamically:
  • Blueprint
  • Spring
Services layer
The Red Hat JBoss Fuse services layer consists of all of the interfaces and implementation classes for each of the embedded services. It interacts with the application layer to communicate with user-developed applications that want to access and use these services.
  • Messaging
Using Red Hat JBoss Fuse's messaging service, based on Apache ActiveMQ, we can create JMS message brokers and clients, then deploy them as OSGi bundles. JBoss Fuse comes with a default message broker that autostarts when you start up JBoss Fuse, but you can replace it with your own message broker implementation.
  • Routing and integration
Using JBoss Fuse's routing and integration service, based on Apache Camel, we can define routes and implement enterprise integration patterns, then deploy them as OSGi bundles.
  • Web services
Using JBoss Fuse's web services framework, based on Apache CXF, you can create JAX-WS web services, then deploy them as OSGi bundles.
  • RESTful services
Using JBoss Fuse's RESTful services framework, based on Apache CXF, you can create JAX-RS web services, then deploy them as OSGi bundles.
  • JBI
Using JBoss Fuse's JBI service you can create and deploy Java Business Integration (JBI) 1.0 service assemblies and service units in JBoss Fuse. See Using Java Business Integration for an introduction to JBoss Fuse's JBI environment.
  • Transaction Manager
JBoss Fuse's transaction framework employs a JTA transaction manager, based on Apache Aries, to expose various transaction interfaces as OSGi services. The transaction manager enables you to create and deploy JTA-based or Spring-based transacted applications in JBoss Fuse. Both the embedded messaging service and the embedded routing and integration service provide easy means for interacting with the transaction manager to implement JMS transactions.
  • Normalized Message Router (NMR)
The JBoss Fuse NMR is a general-purpose message bus whose primary role is to transmit messages between the various application bundles deployed into the OSGi container. In this case, no normalization is required because OSGi places no restrictions on the format of message content.
However, when the JBI container is also deployed, the NMR is also used to transmit messages between OSGi and JBI applications. Normalization must be performed on messages transmitted to a JBI endpoint, because JBI requires that message content be formatted in XML, as defined in a WSDL service description.
JBoss Fuse provides a simple Java API for creating NMR endpoints that receive and process messages from the NMR and for writing clients that send messages to NMR endpoints.
Application layer
The JBoss Fuse application layer is where user-developed applications reside. JBoss Fuse provides many APIs with which you can create client and service applications that access and use the embedded services running within JBoss Fuse.
  • Messaging—Client-side APIs
  • Routing and integration—The Embedded Routing and Integration Service
  • Web and RESTful web services—Front end options.
Download
S.No
File Name
Download
1
The Red Hat JBoss Fuse Architecture.pdf

continue reading

Designed By AMEER BASHA G