Wednesday, February 3, 2016

Fuse Integration Service - Setup JBDS and create first quickstart application

Before we go and start creating our first application, I want to show you how to setup your JBoss Developer Studio, create a small application from the quickstart example and then running it on Fuse Integration Service.

I am using JBoss Developer Studio version 9, you can find it here.
After download the

  • jboss-devstudio-9.0.0.GA-installer-eap.jar

double-click it, and start installing with default values.

After successful installation, we will need install the plugins for Fuse, on JBoss Central view, select software update, select enable early access.


And select JBoss Fuse Development for the plugin,


Click on install, and we are all set to go!

First thing first, we want to create a Fuse project to deploy on the base of Fuse Integration Service, which is OpenShift. If you have not installed it, please go back to my previous post for instructions. So on your JBDS, right click and start creating the project. Select new, maven project, if you have installed the plugin correctly, you should see the "Fuse Tooling Remote Archetype Catalog" under Catalog option, select it.


Select the cdi-mq archetype and for current OpenShift 3.1 make sure it matches the archetype version 2.2.0.redhat-079,


Create the application with 
  • Group ID: com.redhat
  • Artifact ID: mqservicedemo




The project should be created.  The reason we are creating with this archetype is because I want to show you a brilliant idea from Fabric8 that will be very useful. In Fabric8, by using the CDI extension, we can inject service we created in OpenShift to the client by simply specifying the @ServiceName and @Factory in our application. It will automatically locate where the service's clustered Host and Port in our OpenShift environment, since if we are moving to cloud, the server instance will change frequently, so it will be unrealistic to point to real physical location.

Let's start by creating a messaging service named Broker in our Fuse Integration Service, login to OpenShift, which is the base platform of Fuse Integration Service, create a project called demo if you have not already done so.

Add AMQ broker to demo project, we will use the most basic image, choose amq62-basic.


And you will be redirect to a configuration page,  set your application name to broker, and set your prefer ID and PWD, click on "Create" button to start create the service.


It'll take a few minute to startup. And you should be able to see the service up and running in the console.

Go back to JBDS, our quickstart application should be created, navigate the project, go to pom.xml, under plugin docker-maven-plugin add the following environment variable. The reason it can pick up this environment variable is because we have injected the configuration through the ActiveMQConfigurer with Object ActiveMQConfig to set the configurations.
  • <BROKER_AMQ_TCP_USERNAME>YOUR_ID</BROKER_AMQ_TCP_USERNAME
  • <BROKER_AMQ_TCP_PASSWORD>YOUR_PWD</BROKER_AMQ_TCP_PASSWORD>

In the routing code, you should be able to see Fabric8 API, and it is injecting ActiveMQ component with broker name, and setting the alias for the endpoint, change the service name to broker-amq-tcp
    
        @Inject
    @ServiceName("broker-amq-tcp")
    @Alias("jms")

    ActiveMQComponent activeMQComponent;

We are now ready to deploy our application, we are going to build with S2i method, I talk more about in the upcoming post, for now, just think of it as a way to package our code to a docker image. There are few things we need to make sure it's properly setup before we start deploying, first is the docker settings, to get all the info, go to where your install your vagrant for OpenShift and run

  • vagrant adbinfo 

There you will get all the environment details to set, save it for now,

And alway remember to restart your application after running the adbinfo with

  • vagrant provision 

In command line mode, go to your application directory, can start setting the docker environment variables. And then login to OpenShift with your OpenShift client tool, if you don't have it, you can down load it here.

  • oc login

You will be prompt to enter your login ID and pwd, please login, then we can start deploying with command

Once you have successfully deploy the application, please go back to the OpenShift console, you should be able to see your mqservicedemo pod running, check the log, and you should see something similar to this:


That's all for this time! Thanks! Here is the detail video of how to do it. Thanks!


Wednesday, January 27, 2016

Fuse Integration Service- What is Fuse Integration Service?

Fuse Integration Service is your next generation of answers to flexible, scalable integration microservice architecture. 

Basically it contains the best of both what JBoss Fuse brings us in the integration space, and what OpenShift offers in the PAAS platform. So In Red Hat JBoss Fuse Integration Service, we have 150+ components, which act as the smart endpoints in the microservice architecture with simple route, smaller and easy maintainable code base. It provides solutions base on Enterprise Integration Pattern, so developers can follow this pattern without re-inventing wheels every time. Data exchanging between systems is also an important aspect in Integration. It is always filled with unpredictable requirements. Therefore we provide custom way for developer to transform data formats. 

On the other-hand, we have minimized the unnecessary work of developer to the minimum. Basically it'll be down to CODE- PUSH - RUN. The base of Fuse integration service has the ability to receive code pushing signal, and quickly build the application and then take this built image quickly create an running instance. Under this platform, physical information are hidden under an abstract layer, and this abstracts are used by clients. So when moving within the development cycle, the same code are deployed without any changes. And because the size of these instance are very small, AGAIN it fits another characteristic of microservice, small , independent and reusable instance. On the production side, we can also easily scale up and down the allocated resource base on our load. 

With Fuse Integration Service
, not only the developer can integrate their application within enterprise in a more agile approach, less people involve, fewer steps to go through and instant feedbacks, they can also adapting the new DEVOPS approach more quickly. We containerized each software build, providing the container-based platform to deploy and run microservices, since the container only has minimal content, and reuse components from the preceding layers, the size are small enough for the application to deploy quickly and more rapidly. 



The self-service approach allowing developers to choose and setup their required environment on a click of a button. It will ease the load of Operation and give more freedom to developers. We can control the number of resource that will allocate to each microservices, and expand it according to it's load by the orchestration tooling in Fuse Integration Service, also taking care of the authorization of who has right to manage or access particular service. And the way we layer the technology, our integration solution now become HYBRID. We have the freedom to move solution between on-premise base to cloud or vise versa. Providing web/msg communication allowing our data to flow freely between systems and systems. 


So now we can really “connect everything, everywhere” 


Tuesday, January 19, 2016

Fuse Integration Service - Getting your Local Environment ready!

Fuse Integration Service allows developer to package and build application into containerized docker image, the whole idea of how the software is package should not impact how the developer works. But what if a developer wants to start developing without the OpenShift environment?  Since Docker is only available on linux (unless you install conversion tools), in majority of cases, developer would be working on either Windows or Max OS.  So I am going to show you how to setup your own OpenShift in your laptop(desktop).

You will need to have download the following OpenSource software.


Installing above software are pretty straight forward, just follow the default installation instruction. Then we are going to setup our Vagrant virtual machine to run the containerized version of OpenShift Enterprise on our laptop. Go to openshift-vagrant project to get the developer tooling.

Create a folder in your machine, and download the openshift-vagrant by

  • git clone https://github.com/redhat-developer-tooling/openshift-vagrant.git

Go into the openshift-vagrant/cdk-v2 folder, before we start setting up the application, there are a few plugin w have to install, run the following command to install the plugins.

  • vagrant plugin install vagrant-registration 
  • vagrant plugin install vagrant-adbinfo 
(OPTIONAL)And registered your account in the rhn network, and has subscription to RHEL server. To register you account find a RHEL server and register your account 
  • subscription-manager register --username <username> --password <password> --auto-attach
(OPTIONAL) Back to your local laptop command line console, set the registered account info by running following command.
  •  export SUB_USERNAME=<your-subscription-username>
  •  export SUB_PASSWORD=<your-subscription-password>
(NOTE: you do not have to have the RHEL account, if you you don't have one, don't worry about the two above steps)

And finally, go back your machine, under openshift-vagrant/cdk-v2   we can get started to install OpenShift on our laptop run 
  • vagrant up
(NOTE:
If you did not set the SUB_USERNAME and SUB_PASSWORD,  you will be promoted with option during setup,

  • Would you like to register the system now (default: yes)? 

please type "n" to avoid registering.)

If everything installed went well, you should be able to see the OpenShift console (http://10.1.2.2:8443/console) in your browser. 


Run and setup the Atomic Developer Bundle, to setup your Docker environment
  • eval "$(vagrant adbinfo)"

   export DOCKER_HOST=tcp://10.1.2.2:2376
   export DOCKER_CERT_PATH=<your_local_cert_path>
   export DOCKER_TLS_VERIFY=1
   export DOCKER_MACHINE_NAME=<your_docker_machine>

this will disable your OpenShift container, so we will need to restart using vagrant command.
  • vagrant provision
Next, we want to download install OpenShift CLI, 
  • Microsoft Windows
  • Apple OS X
Extract the downloaded file to a folder of your preference, and add the oc to 
  • export PATH=$PATH:<your-oc-extract-path>
Now, in your browser, go to OpenShift Console http://10.1.2.2:8443/console/,  and login with your register ID/PWD, if you did not supply anything, type in admin/admin (or anything you prefer) as ID/PWD.  Create your first project by clicking on "New Project":


Type "demo" for the project name



Once you see the project on the console, congratulation!



You have successfully setup the environment.

Tuesday, January 5, 2016

Red Hat JBoss Fuse - Switchyard in OSGi

If your have ever played with JBoss Fuse Service Work, then you will probably know this already. So what exactly is switchyard?

SwitchYard is a structured framework for developing integration applications using the design principles and best practices of Service Oriented Architecture.

It supports the SCA, SCA stands for Service Component Architecture, it is basically specifications that describe a model for building applications and systems using a Service-Oriented Architecture. By applying the standards way of describing SOA's available components and services in integration solution, we will then have this abstract layer of services, that is not specifically belong to single language, or implementation. By implementing this standard, we will have a complete, well define SOA architecture.

In previous version of JBoss Fuse and JBoss Fuse Service Work, one of the dividing factor between them is the containers they are running. JBoss FSW runs in JBoss EAP which is the JavaEE container. And JBoss Fuse runs on Karaf, the OSGi standard container. But now that the Fuse can run on both JavaEE and OSGi, what about Switchyard? I can very happy to tell you, YEP! it's OSGi ready now.

Let's take a look at Switchyard features that is available in JBoss Fuse server.

These ones are the basic switchyard feature, and the libraries you will need. 


smooks    
switchyard
switchyard-internal-core  
dozer      
xalan-deps

                             
These ones are the feature libraries of the components in Switchyard


switchyard-camel-jpa-hibernate              
switchyard-amqp           
switchyard-atom                               
switchyard-bean                               
switchyard-bpel                      
switchyard-cdi                                
switchyard-camel
switchyard-camel-cxf
switchyard-file
switchyard-ftp  
switchyard-http    
switchyard-internal-http                      
switchyard-jms
switchyard-jpa
switchyard-mail
switchyard-mqtt                               
switchyard-netty
switchyard-quartz                                      
switchyard-rss                                
switchyard-rest                               
switchyard-internal-rest                      
switchyard-sca                                
switchyard-internal-sca                       
switchyard-sql  
switchyard-soap
switchyard-internal-soap    
switchyard-sap






Then the rest of the features are quickstarts and demos for you to play with.
By adding the required library into container or add them to your application profile, it will enable the Switchyard running on Karaf.

Let's take one of the quick start demo, and see how to deploy it in Karaf or Fabric environment in JBoss Fuse.

Karaf - Standalone OSGi container

Karaf will be a simple and standalone OSGi container, it has fewer steps, basically, all we have to do is installed the feature and then it's ready to go.

The repository url should have already set in JBoss Fuse, all we have to do is to install the demo feature.

  • features:install switchyard-quickstart-camel-cxf

This will download and install the feature and we can start play with it.

Fuse Fabric - Set of Standalone Managed OSGi container

But, with Fuse Fabric, because we have another layer of control, the profile, therefore we will need , first create a profile,  (Make sure you have created your Fuse Fabric beforehand.)

  • profile-create demo-myswitchyard

Create a small container for this small service

  • container-create-child root mydemo

then we add the features we need in the profile, deploy the profile to a empty container, and then we are done!

  • profile-edit --features switchyard-quickstart-camel-cxf-binding demo-myswitchyard


Give the container a few good minutes to down and install the bundles in the container, type

  • container-list 

see if every container shows success in their status.
JBossFuse:karaf@root> container-list 
[id]      [version]  [type]  [connected]  [profiles]      [provision status]
root*     1.0        karaf   yes          fabric                  success          
                                          fabric-ensemble-0000-1                   
                                          jboss-fuse-full                          
  mydemo  1.0        karaf   yes          default                 success       

     
If this is what you see, then congratulations!!
This CXF binding demo is a very interesting example, basically it shows usage of SOAP with Camel Cxf component. The SwitchYard service binds to a Cxf URL and we can call the service via the URL of the CXF component.


This demo is an order service, the order is send by client through web service, the data is then send to Camel, which is going to route the message to it's destination, that is the warehouse service, checking the inventory.

The switchyard.xml show the architecture of the demo. The composite, which is the large blue rectangular shape base. It defines the boundary of your application, anything that is inside the rectangle is your application, and anything outside are external resources. We see there are two endpoint expose which let's outer resource to call. And an endpoint that calls the external resources.



In the middle you can see there are two Camel components, which passes the message we got from client, then process it within camel route then pass it out to next step in Switchyard, so how do we integrate Camel with switchyard? Simple, let's look at the Camel route here:



Notice some of the components started with switchyard? That's right, by creating a switchyard endpoint, it will be available to receive or produce data to your switchyard application. And to start the demo, simple run

  • mvn exec:java -Pkaraf -Dexec.args="Boeing 10"

Which will start the ClientProcessor in the project, and send a SOAP message ordering Boeing with amount of 10. Login in the to the console http://localhost:8181/hawtio with your ID/PWD.

Click on the container we have just create.
 It will take you to the container view,  here you will be able to see what is happening.
What I love about this version of JBoss Fuse, is now you get to see all the route at once,



Alright, that's all for this post. More about Switchyard in next one. 

Tuesday, December 29, 2015

Red Hat JBoss Fuse - Moving Camel application between OSGi and JavaEE containers

Now that JBoss Fuse supports both OSGi Karaf and JavaEE JBoss EAP container. When to use which one, is there any best practice for which container to use? And same as the answer as any other software related question, well, any questions in life actually. "it depends" .... Situation varies between cases, here are my point of view, you many like it or disagree, I am very happy to hear more of your thoughts.

Here is the thing, I think, it is BEST if you stick with Karaf container if possible for now. It is more light weight, which means you can deploy application much more quickly and expend faster horizontally with application distributed everywhere. And the may OSGi manages the lifecycle of the services allows you to dynamically deploy and undeploy service without affecting the others service in the same container. That, is very important in for mission critical services. So if you get to choose which ever to use go with Karaf.
What I also believe is, in an enterprise you should not be restricted to use Single kind of container, different container framework exist for a reason. Especially if you are providing a web application with EJB, JARs complex application glue together to serve as the core business for the web application. Maybe it's a legacy application that has everything done in the Application server. Or it simply has too many non-OSGi compatible libraries to work with. Then I will go for the JBoss EAP scenario.

So how to move from OSGi to JavaEE container or vise versa? Moving a bundle from OSGi to JavaEE is dead simple. But please note, use the Spring framework instead of Blueprint, if you are using OSGi, I would first convert it Spring then work with it.

In this case I will be using a WAR application, since most people use this format in JavaEE and it is supported in Karaf as well.

So there are few ground rules if you want to switch back and forth between the containers, is


  • Use Spring Framework
  • Make sure your Camel route is placed under META-INF under webapp and named *-camel-context.xml

  • Set you plugins to generate metadata needed for OSGi container.
    • Add maven-bundle-plugin        
       <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.7</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <supportedProjectTypes>
            <supportedProjectType>jar</supportedProjectType>
            <supportedProjectType>bundle</supportedProjectType>
            <supportedProjectType>war</supportedProjectType>
          </supportedProjectTypes>
          <instructions>
            <Bundle-SymbolicName>camel-blueprint</Bundle-SymbolicName>
            <Private-Package>com.redhat.springtest</Private-Package>
            <Import-Package>*</Import-Package>
          </instructions>
        </configuration>
       </plugin>

By sticking with these rules will allow you to create a project that can deploy on both containers.
In JBoss Fuse Karaf Container,

  • Install with Profile or using OSGi command, 
    • war:mvn:com.redhat/springtest/1.0.0-SNAPSHOT/war?Web-ContextPath=springtest
  • Make sure to have feature-fabric-web profile in your container

Running JBoss EAP Container with Fuse application.

  • Deploy and install by
    • Drag and drop the WAR file under deployment folder
    • Using Console/CLI deployment
  • Make sure Fuse subsystem is installed and activated. 
  • Remember to disable ContextLoaderListener in web.xml

Here is a video showing how to move application between containers.