IntroductionWhat? 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 onesWhen 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 ESBSee 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:
ConclusionsOf 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.