I am using JBoss Developer Studio version 9, you can find it here.
After download the
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.
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
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!