Thursday, September 4, 2008

POSOS: Plain Old Services Objects in JBoss ESB

Introduction

What? One more buzzword? You can complain with Burr Sutter, he is the guy that created this one for what some customers are wondering and they asked me how do that possible in JBossESB! The question is: "We would like use or reuse as easy as possible my just plain Pojos or "legacy beans" acting as ESB Actions configured in the listeners from protocol's providers in ESB.

ESB Traditional Actions for Experienced Developers...Easy Pojos for non-experienced ones

When you are writing your ESB Action classes, you have some rules to follow, for instance: a) extends AbstractActionLifecycle or , b) A Constructor with a ConfigTree object as a parameter , c) The process methods must returns a Message as well as you need a Message parameter using this type, so your simplest ESB Action is not that easy for non-experienced ESB Action developers.

Ok, Show me this POJO that can run inside JBoss ESB

See the following pojo:

Easy right? See the changes I did to enable this simple POJO as an Action Processor for a Listener in ESB, basically creating two annotations: @In and @MessageParam, which can tell me which methods from the pojo I have to invoke from my processor method in the action, as well as the parameters that I can get via the attributes stored in the Message.Body :

Basically, what I did was a first action, that is traditional action, where I put a value in the message body identified by the name "s", which is the value from "name" in the annotation @MessageParam, so the value will be transfered for my methods as a parameter properly, my action is very simpple as you can see in the following image:



On this point, I am using a strategy similar you can see at any regular Web application, which a portion can store some information into some context that will be accessible when necessary.

The convention here is that, I am telling that the annotation @In (like Seam) in the method must be processed into the BUS, in addition, the parameter @MessageParameter tells me that I have to get an object identified by name "s" from the Message.Boby from my ESB Message.

To do that, I created an Action that can accept into one of their properties, which a called "classses", a list of full classes names separated by commas. It is the easiest way to discover the classes without use any other sofisticated engine. See those actions configured into JBoss ESB Eclipse Plugin in the following image:


The following code shows how I configured my jboss-esb.xml, and the configuration of the actions. Look that I can fill in the classes property in how many annottated pojos I want, once they are annotated with our "Esb" annotations:

Once again, the only thing I did on my pojo was add the following annotations, as you can see in the following image:


Conclusions

Of course something much more sophisticated could be done, but like I did is easy for anybody understand, maybe in the future use some similar strategy that RestEasy does, or even create something in memory using JavaAssist.
Another point, I also created annother annotation @Out which would be useful when you change the information inside the parameter that you receive from Message.Body, but after the method you wanna take the changed value to the Message.body context with the changed information... Perharps it sounds like a bijection originally a concept from in JBoss Seam applied for JBoss ESB as well. The actual sources are not the most beautyful, but are working fine, e-mail-me if you need the source code, which basically runs as any other regular quickstart.

I hope someday see such feature like that out-of-the-box in JBoss ESB, while it is not true, I am happy with I have done.

6 comments:

Unknown said...

This is a great concept. Please also show the jboss-esb.xml and perhaps the wrapper custom action that performs the "injection" into the POJO. A more complex example would use Smooks earlier in the action chain/pipeline to render POJOs (e.g. Customer, Order) that are injected/outjected into/from this "POSO"

joakim said...

Nice idea with the annotation approach. But, in my mind it would be nicer if the POSOS could be defined directly in the action class attribute, thus the annotation processor would be invoked automatically.

/ Joakim

Anonymous said...

Have you heared about 9Dragons which you need use Atlantica online Gold to play, and you can also borrow Atlantica Gold from other players? But you can buy Atlantica online Gold, or you will lose the choice if you do not have cheap Atlantica online Gold. If you get Atlantica online money, you can continue this game.
Have you heared about 9Dragons which you need use Entropiauniverse ped to play, and you can also borrow Entropia Universe Gold from other players? But you can Buy Entropia Universe Gold, or you will lose the choice if you do not have Entropia Universe Money. If you get cheap Entropiauniverse ped, you can continue this game.

Anonymous said...

Do you know cabal online alz? I like it.
My brother often go to the internet bar to buy cabal alz and play it.
After school, He likes playing games using these cabal gold with his friend.
I do not like to play it. Because I think that it not only costs much money but also spend much time. One day, he give me many cabal money and play the game with me.
I came to the bar following him and found buy cabal alz was so cheap. After that, I also go to play game with him.
Do you know eve isk? I like it.
My brother often go to the internet bar to buy eve online isk and play it.
After school, He likes playing games using these buy isk with his friend.
I do not like to play it. Because I think that it not only costs much money but also spend much time. One day, he give me many cheap eve isk and play the game with me.
I came to the bar following him and found buy eve online isk was so cheap. After that, I also go to play game with him.

Anonymous said...

I always heard something from my neighbor that he sometimes goes to the internet bar to play the game which will use him some LOTRO Gold, he usually can win a lot of Lord Of The Rings Gold, then he let his friends all have some buy LOTRO Gold, his friends thank him very much for introducing them the cheap Lord Of The Rings Gold.
I am so happy to get some ro zeny and the ragnarok zeny is given by my close friend who tells me that the iro zeny is the basis to enter into the game. Therefore, I should cheap zeny with the spare money and I gain some ragnarok online zeny from other players.

Unknown said...

Hey, this is great.. can i get the src for the code( i guess i need only annotation impls right) you described in POSOS. thanks in adance... aravind.kbase@gmail.com
thanks again