Skip to main content

Posts

Showing posts from 2014

JBoss Fuse - Implementing WebService with Camel using CXF SOAP and Restful with CXFRS. Part Two

Continue from last post, this time I am going to add a restful web service endpoint to our insurance application, and show you use the CXF producer. :)


Similar to CXF web service, we need to create a resource file, but this time, instead of an interface, we need to create a java class. Within the resource class file, we have specify 2 things, the context path and the url path of each functions for the restful service. So in the java file below, you will see that I have declare "status" context path for our status service, "/custId/{id}" for getting the status and "/restcancel/{polno}" for canceling claim with restful API.


package org.blogdemo.claimdemo; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/status") public class StatusService { @GET @Path("/custId/{id}") @Produces(MediaType.APPLICATION_JSON) public ClaimStatus status…

JBoss Fuse - Implementing WebService with Camel using CXF SOAP and Restful with CXFRS. Part One

Some friend of mine in Japan asking if I could do a simple demo on Camel CXF,  So here it is :).
This demo is about an insurance simple online claim application and status update. I will show you how to use Camel CXF to quickly setup an WebService, also setup Restful WebServices in few very easy steps.

In this demo we are going to setup a web service that takes in customer's insurance claim application, also provide another cancel function in case they have changed their mind.

One of the reason I love so much about Camel is that I don't need to deal with different context of the data, like XML, JSON... I mean they are ok, but I like POJO more, as a Java developer they are more meaningful and much easier to play with. So now we are going define some POJOs that we are going to exchange in this demo.

These two POJO contains the application information required (ClaimInput) and the result of the application submission (ClaimOutput).
package org.blogdemo.claimdemo; import java.util…

JBoss Fuse - File Connector with Split Pattern and JDBC connector with Error Handling - Part Two

This is the second part of the demo, "JDBC connector with Error Handling ", please take a look at the previous blog post. You can also find the finished code base here.

In the XML file, you'll find there is a VIP status, this indicates the process fee we need to charge per transaction, for DIAMOND class VIP, it's $1, $2 for GOLD and $3 for other accounts.

Using JDBC Connector, we first must create datasource setting, either within Camel context xml or in Fabric8. To make testing easy, we will set the setting in the datasource.

XML
Here you will see I use the H2 Database in memory, I am using it because it's easier to setup, without the need of installing a database. If you want, you can always change it to your desire database, all you have to do is just replace the driverClassName and url, along with the ID and password to access the database. And then it's always a good idea to include an transaction manager so we can set the transaction policy. 
Before calling …

JBoss Fuse - File Connector with Split Pattern and JDBC connector with Error Handling - Part One

This demo is slightly longer then the ones I done before, So I will break it into 2 parts, and try to keep each section as simple as possible, and then combine 2 simple section into a bigger demo. During the process I hope you can find it's very simple to integrate, process data and information with JBoss Fuse.

Part One
=========

File connectorSplit Pattern

We are going to take in XML file from different branch in a directory, each contains cash deposit, cash withdraw and transfer data, depending on the type of transaction, we spilt this XML file into different sections, then send them to different services for further process.

The format of a XML looks like this.  A02Gold-20A02GoldA0120


First create a route that has a file consumer endpoint that read xml files from directory, there are many different options like, readLock - locks the file when reading it , recursive -look for files in all the sub-directories as well , extra.. for more options please read the documentation. After r…

JBoss Fuse - Connecting to Twitter and the Aggregator pattern

If you think connecting to Facebook is easy with Camel, try connecting to Twitter! It's every easier!
Before connecting to Twitter, make sure you have register a twitter developer account, and go to https://apps.twitter.com/. Create a new Twitter App.

There are a few mandatory parameter for authentication if you want to play with Twitter, they are :
consumerKey- The consumer keyconsumerSecret - The consumer secret accessToken - The access tokenaccessTokenSecret - The access token secret
Also Twitter has Consumer  as it handle mostly polling functionality, such as search from content, streaming tweets from twitter etc.

timeline/home - read or polls tweet from user homesearch - search specific keywords,streaming/filter - get streaming of data from twitter.
Whereas Producer handles tweeting and calling of twitter API, they might also include searching and timeline polling too.

directmessage - gets the message search - search for keywordstimeline/user - polling from users For more deta…

JBoss Fuse - Connecting to Facebook

Got your camel working? now it's time to have some fun, how about update your Facebook status using Camel? From Camel 2.12 onwards, Facebook endpoint was added, which makes it a lot easier to implement.

So how does it works? Basically, Facebook provides a unofficial Java API called "facebook4j", so Camel uses this API to implement the integration with Facebook. 
Basically, Facebook requires OAuth for all client application authentication, please go to the Facebook developer site and register.  


And create a new application, because Facebook require you to set authority to different function for each application. For instance, with application A, you grant the publish and poll right with all your photos, and application B you grant the location information to it. So click on the "Apps" tab on top of the page. 

Choose website, 
Give a name to your application, and choose the type of your application,

Skip or go through the quick start.  After that, you will arri…

JBoss Fuse/A-MQ - Playing with Insight/Elastic Search Tech Preview of Fuse

This week in Berlin, I met awesome Red Hat SA Roel Hodzelmans , who showed me the "fun stuff" that you can play with in JBoss Fuse, although this is still a Tech Preview function, I think would be great for people to take play with this and give as much testing as possible.

Kibana is an open source browser based analytics and search dashboard for ElasticSearch.

Steps to do an Insight/Elastic Search demo of Fuse, make sure the environment has enough disk space.

1) In the root container add the Kibana profile - this is the management console for Elastic Search.


It will add a new tab next to Runtime, Wiki, Dashboard, Health and Insight. The preparation takes a couple of minutes, depends on your resource.


2) Add the insight core profile to all containers where you want to capture the logging from




3) Create a new profile or profile version to which you want to add insight in the camel parts to,



then add insight-camel feature to the features of the profile




4) Migrate a container …