Friday, September 23, 2011

JBossInBossa 2011 : Brazil


Next October 8th, we will be hosting the largest Brazilian JBoss User Group Conference in brazilian federal capital : Brasilia.

In 2010 we made a great conference in São Paulo, but this year we decide bring to Brasilia, once it is closer to Northeast and North region in Brazil, besides this city is one of the most important cities for opensource movement , there you can find a lot of government agencies in the public sector in Brazil, where they are consuming many opensource technologies.

We are proud to offer a high-level of speakers and sessions , covering many JBoss Technologies, in the speakers list the audience will be able to find some of JBoss Community stars, such as:

  • Flavia Rainone (Core Developer on AS7)
  • Mauricio Salatino (Committer in Drools/JBPM5)
  • Alexandre Porcelli (Contributions in Hibernate and Drools)
This year we made a Call 4 Papers with a very great level of speakers and sessions, so people will meet a lot of new speakers.

We also will have some Red Hat employees, from several departments, such as: Support, Consulting and Solutions Architects.

We used Google Translator in order to allow you check our agenda , and the best stuff about that event, the whole content we are charging just equivalent to US$25 , cheap hun?

Special thanks for James Cobb and Cheyenne Weaver for helping with our JBUG branding. 


Tuesday, January 18, 2011

Enabling RestEasy as JAX-RS Impl in Scalate

Scala as a language and its community is gaining a lot of attention, in fact, there are certain use cases where Scala offers incredible advantages over the traditional Java Language "as it is".

Although my experience with Scala so far is completely away from Web technologies, I've seen a lot of discussion about this matter, and a good solution for web applications can be basically a very simple composition:

  • HTML5 + REST Services [JSON]
  • HTML 5 + JavaScripts Toolkits such as JQuery and other + REST Service + [Many media types]

For the scenario that I mentioned above, I found out the framework Scalate, a good option for who is looking for a good getting started with Scala and Web.

 If you go in the Scalate's Getting Started Tutorial, everything works fine.  I spent the last couple of weeks researching a lot about which IDE to use, and at this moment honestly I recommend you use InteliJ Idea Community Edition with Scala plugins, it works incredibly fine and pleasant.

Well, but this post's title is about to enable RestEasy in Scalate Projects, so here will go deeper in this subject: Scalate by default comes with Jersey support implementation, which is another JAX-RS implementation, nevertheless for obvious reasons :) I prefer JBoss RestEasy, and in this post you will learn how you can change your scalate project to use RestEasy instead Jersey.

Everything I made is on my github online repository, I called this "version" of my scalate+resteasy project: easyscala, and you can checkout all the sources from here: https://github.com/edgars/easyscala

Changing the pom.xml

This is the first task you have to do, so you have to add RestEasy dependency in the pom.xml, although there is an important detail that I noticed when I tried to do that:
  • If you do not ignore the org.slf4j package, you will get an error, that I had not chance to go deeper to check the reason, that's why when I added RestEasy dependency I excluded the reference for this package, maybe some version conflicts of any other stupid thing that I had no time to check.

         org.jboss.resteasy
         resteasy-jaxrs
         ${resteasy-version}

   
   org.slf4j
    *
   

          compile


Changing the web.xml

Another change that I did, was in web.xml, where I removed the Jersey Servlet Filter's and any related configuration, and I added the RestEasy declaration as the following code:

     resteasy.scan     true

      resteasy.servlet.mapping.prefix      /resteasy
 

  Resteasy
  org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
  



  Resteasy
  /resteasy/*
  

With a few changes, I was able to run the first REST Service made with JBoss RestEasy, look that we have a very standard JAX-RS Class in the following example:

package org.jboss.easyscala

import javax.ws.rs.{GET, Path, Produces}
import javax.ws.rs.ext.Provider

@Provider
@Path("/root")
class RootService {

  @GET
  @Path("/hello")
  @Produces(Array("text/xml", "application/json"))
  def getMediaType = "hello"

  @GET
  @Path("/hello")
  @Produces(Array("text/html"))
  def getHTML = "hello"
}

In the class above, we have 2 methods, according to the mime type (media type) that this service is requested, one of them will send the response. Another good point, at this moment, you cannot see any JBoss RestEasy proprietary extension. Obviously according your needs, you may add some helpers.


Conclusion


Scala and their related projects and solutions are gaining a lot of attention, it combines two programming models: OO and Functional, and this combination can make our codes easier, smaller and smarter. I cannot predict that much, but I am working in some specific Use Cases that were totally suitable for Scala, I am not talking about boilerplate code, but about less code with more power, and getting a huge difference when performance is a relevant issue. If you like JBoss tecnologies, like me, this is the first post where I will try show some good and relevant combinations.

Friday, November 5, 2010

Polling any Database table with JBoss ESB 4.9 and Apache Camel - Part 1

Introduction


Poll a database table is very common use case when you are integrating systems and applications, according EIPs(http://www.enterpriseintegrationpatterns.com/): Shared Databse is one of Integration Styles available in the industry.

JBoss ESB 4.9 : Support for Apache Camel 

IMHO, this is the greatest improvement in JBoss ESB from the last 3 years,  we community owe this job to David Ward, which pushed this implementation in that newest Community JBoss ESB release.  David wrote about getting started with Apache Camel and JBoss ESB here: http://community.jboss.org/wiki/CamelGateway. If you need some basic overview about Apache Camel, I recommend you take a look on Camel website:  http://camel.apache.org/.

Where is the benefits of Apache Camel in JBoss ESB?

First of all, we have a plenty of new gateways components available, such component's list is huge, you can see them here. In Apache Camel we have to be aware about the difference between the components, basically there are:
  • Consumers - Which can be message listeners from the URI protocols
  • Producers - Which can post a message into the protocol URI
There are components that commonly can be both, but you might see some components that can be only Consumers or only Producers. It depends of the protocols nature or any other related aspect. 

For that demo, I decided use the JPA Component, as which can be both a producer and consumer.

Demo Use Case

We have many customers asking how they could integrate legacy applications, or even applications written in different platforms, such as .Net or PHP, for this matter we have one thing in common: The Database can be shared between many applications. I am not talking about ETL or even Data Services Federation, at this point I want to just get a row from some table and consider it a "Message", as which I can do anything I want using JBoss ESB Actions.

To turn my demo more realistic I am using the very well known opensource CRM: SugarCRM, which has a table called: Lead, which keeps every leads from the system stored. See Image 1 to see my local SugarCRM instance running:


Image 1 - Sugar CRM with my Leads

The SugarCRM stores the data into any relational database, in my case I am using MySql.

The ESB Project

In my ESB Project, I just have to add an Entity class that will reference the Lead Table, in that case I created the following table:

@Entity
@Table(name="leads")
@NamedQuery(name = "NewLeadsQuery", query = "select x from Lead x where x.status='New'")

public class Lead implements Serializable {
 private static final long serialVersionUID = 1L;

 @Id
 @GeneratedValue(strategy=GenerationType.IDENTITY)
 @Column(unique=true, nullable=false, length=36)
 private String id;

    @Lob()
 @Column(name="account_description")
 private String accountDescription;

   .....

In that Entity you can see that it is a very basic JPA Entity, which contains a named query that will return every Lead that the property status is "New", in other words: Every single Lead will be dispatched to JBoss ESB as a Message, and now you are asking yourself: How ? See the next topic.

Declaring a Camel Gateway in JBoss ESB

What is more important is to know the components that you will interact with, and notice that each component has its dependency, in my case with JPA, I need to add into my project lib folder the camel-jpa-VERSION.jar, which is my component library, I have to do that, because AKAIK just the core camel libraries are in JBoss ESB classpath. Here is my jboss-esb.xml config portion for it:



   
    
   
 


There is a point that I'd like to call your attention: The & symbol as it is declared in XML you have to work with the & representation replacing that symbol

Now, you are able to create any Service in JBoss ESB and several actions to interact with your Message.

In my final release of that demo, I am using JBoss BRMS/Guvnor, that will receive the Lead row as an Object and will decide if it is a Lead that have to be worked by a Sales Rep or an Inside Sales Rep, according some fields on that "Lead fact"


In my upcoming new things in that demo I will have 2 consoles: 1 written using Swing which will listening a JMS Queue for the Inside Sales, which supposedly are inside the company's office, and if it is a lead for an Outside Sales Rep, it will go to an Infinispan Cache, and it will be accessible through an WebSocket HTML 5 Client.

Last Tip about JPA Component

Once you consume a row to the database, maybe you need to change at least the column that makes the row available to be polled, in our case "status=new", So, you can "mark" that row with a new Status, or invoke any other operation, just adding the @Consumed annotation in any method in the JPA Entity.

// Changing 2 column's values in the database, so a polled row, will not be consumed more than one time
@Consumed
 public void checked(){
  
  this.setStatus("EAI-Partner"); 
  this.setStatusDescription("This Lead was Forwarded to a Partner");
  
 }





Next Steps

Partially I have the demo done, I will move that to my Mac, where I can do fancier screencasts, and than you will be able to see it working.


Tuesday, August 10, 2010

RestEasy on GoogleAppEngine: CoreREST

I've been quite busy the last couple of months, with a lot of meetings and customer calls, so far the time to study, to create and researching is becoming rare, activities that I love are becoming less frequent day by day. I have a particular viewing of video games: I hate all them and I hate invitations to play with, I prefer play soccer for real, but in my spare time, between an airport and other, I decided give myself another chance to enjoy Ruby, and to discover why lots of people says so good things about that. So I combined a plenty of subjects that I really enjoy: JAX-RS with RestEasy, JSF2.0 (Sorry, I know a lot of people prefers GWT) and Google AppEngine. The result combination was an open project called: CoreRest (http://corerest.appspot.com)




CoreREST, is a kind of "PaaS"(Platform as a Service), which runs on Google AppEngine, which allows users to create their own lightweight "WebServices" based on REST approach using Groovy, and as sooner as possible with Ruby(powered by JRuby). I also will add many out-of-the-box APIs, such as: Smooks, and XStream, thus will possible: Transform, Convert and create really rich Services.

I used RestEasy 2.0, the JBoss implementation for JAX-RS standard, led by Bill Burke, which runs smoothly on Google AppEngine. I also, decided use another JEE6 standard in GAE: JSF 2.0, which to be honest: Without Seam, JSF seems to be a "Barbacue without salt", but in the end, it is running pretty well.

For persistence, as Google uses BigTable, a noSQL Implementation, the JPA Provider recommended by Google I really didn't liked, so I am using Objectify, which for me was more pleasant and easy to use.

In this first blog entry, I will just let you create and expose a basic "Service" in CoreRest. To do that, see the following instructions:

1- Open http://corerest.appspot.com

2- Click on Groovy logo icon

3 - Fill the following information:

3.1 - Script Name: This is the script name, which will be a kind of "endpoint name", so it will be the key for service invocation, put any simple name for it, your name for instance.

3.2 - URL Mapping - This is the URI that you want for for your service, you will put: /{firstname}/{lastname} .

3.4 - And the Source, will be the groovy script:

String response = lastname.toUpperCase() + ", "+ firstname;
return response;


3.5 - Click on "Save Script"


 


Well, what is happening behind the scenes:

a) the URI is the extension for the "endpoint name", and the location where you will add the variables, exactly as you do according the standard on JAX-RS. In the URL: /{firstname}/{lastname}, we will have 2 variables available for Scripting context, besides the variable "response", which is the variable to return the response as a String, although CoreRest will support some Media types, I am still working on it, once it is totally possible using RestEasy.

To test you script, you just may call you service according the following URL:

http://corerest.appspot.com/service - (Service is the ROOT for endpoints)

http://corerest.appspot.com/service/tutorial/Edgar/Silva

Next Steps:
I will try work on it, improve the UI and the user experience. I would like to say thanks to eXo Platform, for the Groovy Syntax hightlight, and Alexandre Porcelli that helped me to not use Java Regular Expressions and make my code easier :), and Eder Magalhães that tested CoreRest with me last night.

I sooner I get this code not so dirty though, I will publish and let it opensource somewhere, maybe GitHub, once I could at least to do my first commit there without any error :).

Saturday, May 15, 2010

JBoss Technologies presented at 1st nosqlbr

 This saturday, May 15th, we had the 1st Conference about noSQL technologies in São Paulo, Brazil, promoted by Caravela Technologies, in fact, organized by Alexandre Porcelli (former Drools and Hibernate Commiter) - The ANTLR Guy, with his team and his lovely "gang"(his family).

The event started from a simple post on Twitter (#nosqlbr), and from a original planning for 20 people (no regular ones but geeks) going to a bar and between a beer and a cairpirinha, the people would have some discussion about noSQL technologies. However, Porcelli is brazilian, and he never gives up, and in the end the 1st nosqlbr had about 250 attendees in a fancy hotel with an incredible cofee break , good people to talk and so on.

Thursday, April 8, 2010

JBossInBossa 2010 - JBUG:Brasil Conference / May 7th, 8th


We are very happy to announce the JBossInBossa 2010 , the Brazilian JBoss Conference organized by JBUG:Brasil and sponsored by Red Hat and others, which is scheduled for May 7th and 8th.

The audience will be able to meet the following international speakers:
  • Pete Muir , Seam/Weld Project Lead
  • Benjamin Mestrallet, eXo Platform CEO
  • Mauricio Salatino, PlugTree CTO/ Drools Committer 
But the conferece will be in Brazil, so we will count with some JBoss employees providing Workshops and/or Sessions as well, see the following list :
  • Alessandro Lazarotti,
  • Bruno Rossetto Machado,
  • Edgar Silva
  • Flavia Rainone
  • João Paulo Viragine
  • Leandro Abite,
  • Rafael Benevides,
  • Ricardo Ferreira
  • Rodrigo Freire
  • Samuel Tauil
  • Others
We would like also to say thanks to another brazilian companies that are providing really great and worth speakers for our Workshops:
  • Caravela Tech: Alexandre Porcelli (CTO) -Drools Workshop with Mauricio Salatino (Salaboy)
  • Voice Technology - Antonio Anderson Souza (Voice Technology), André Pantalião - Workshop: Social Networking by Phone - Utilizando SeamTelcoFramework
  • Caelum - Paulo Silveira - Workshop: JPA 2.0 na prática, com Hibernate
  • GlobalCode - Alberto Lemos aka Dr.Spock , Vinicius Senger , Yara Senger- Workshop: JSF 2.0 with JBoss 6.x

 We would like to say thanks to James Cobb and his team at JBoss.ORG, they are the people behind the arts, logo and every good visual impact that we are promoting in JBossInBossa Website (http://www.jbossinbossa.com.br).

This is a way to share knowledge, energy and everything good, it is our way to say thanks to the large JBoss Community in Brazil, as well as to celebrate our 3rd birthday of official JBoss presence in Brazil.

This is our agenda for May 8th:

9:00 - 10:00

Seam 3, Weld, CDI , JEE 6 - Pete Muir

10:00 - 10:20

Cofee-Break

10:20 - 11:20

JBoss Application Server 6 Revolutions! - Flavia Rainone

11:20 - 12:20

SOA Showcases - Teiid(MetaMatrix) e BRMS - Ricardo Ferreira


13:20 - 14:20

Plataforma de Portais GateIn - Benjamin Mestrallet

15:30-16:15

Gerenciamento Efetivo de Ambientes JBoss com JOPR/JON - Rodrigo Freire e João Paulo Viragine

15:05-15:30

Cofeebreak - Intervalo

15:30-16:15

Apresentando o Projeto XSeam e Arquiteturas de Referencia em Seam  Alessandro Lazarotti e Rafael Benevides

16:15-17:00

Breakingwoods & JBoss para plataformas de Integração de Sistemas - Edgar Silva

17:00-17:50

Drools Fusion e DroolsFlow - Mauricio Salatino

17:50-18:50

RichFaces 4 e JSF 2.0 - Pete Muir


In the next year, we are already planning a bigger event, who knows in another location, I hope some place like Rio de Janeiro or Fortaleza :)

Cheers

Edgar


    Friday, April 2, 2010

    Speaking at Jazoon 2010


    I am very happy to be accepted to be speaking at Jazoon 2010 with my paper entitled: "Opensource SOA on Steroids: Combining the robustness of JBoss ESB with the flexibility of Apache Camel".  I am very excited with that, and already planning a cool presentation with a lot of energy and ready to share many good topics with the audience.

    Other much more relevant and famous JBossians were also accepted, see the following list :
    • Dan Allen
    • Emmanuel Bernard 
    • Heiko Braun 
    • Jean Deruelle 
    • Wesley Hales 
    • Aslak Knutsen 
    • Anil Saldhana
    See the full list here: http://jazoon.com/Conference/Speakers 

     I am proud to be representing the JBoss Solution Architects Team from Red Hat, and happy to have the chance to meet those incredible technicians there,  as well as all Java community that will be present there.      

    I will try bring with me a "Cachaça bottle"  in order to prepare for my friends some "Brazilian Caipirinhas (http://en.wikipedia.org/wiki/Caipirinha)", which is a really good mixing... Essentially as JBoss ESB and Apache Camel can to be.

    Thursday, February 25, 2010

    IRC Gateway in JBoss ESB via Apache Camel

    The breakingwoods project is happy to announce a new contribution: The initial Apache Camel fully integration. 

    Right now, we are accepting any suggestion, contribution, testing, complains... money etc, anything you judge valuable for make this component a really useful new JBoss ESB 4.7 Component.

    Basically what was done is just a new Gateway that is able to listen the Apache Camel Components, for awhile we just tested two of those: File and IRC.

    IRC can be a good way to receive events or messages that can be delivered to an existing JBoss ESB Service, in other words, this is the finnest integration between these two opensource projects: JBoss ESB and Apache Camel, and the community behind breakingwoods is happy to deliver this new component.

    How it Works

    First of all, we need just to declare a new Service, that will be listener for Apache Camel.



    The properties for this components are the following:
    • protocol-uri : Apache Camel Endpoint URI
    • destination-category : Service Category that will receive the events from the Camel Layer
    • destination-name: Service that will process the event that happened on Camel Layer
    Once you have it done, you will be able to check the event coming from IRC Channel to JBoss ESB.

    We hope that the community enjoy this!


    Check it out in http://code.google.com/p/breakingwoods

    Tuesday, February 9, 2010

    The Bossa Nova Way: JON success cases in Brazil, the rare accent again

    If you lost this presentation during the last JBossWorld 2009 in Chicago, it's your the chance to watch 3 real success histories coming from Brazil.


    JBoss Operations Network - JON is the productization of the Jopr project.  A JON subscription allows customers to perform enterprise management of not only JBoss Application Server , but also several important components such as the OS, Network traffic, Filesystems, Apache Web and Tomcat Servers, as well as internal services utilized by the JBoss Application Server, including: Hibernate, JMS, and Connection Pools.  It allows the JBoss to be recognized as a real "Enterprise Offering" in the market.   JON can be thought of as an enterprise level administration console for JBoss.  As Chris Morgan, Product Manager at Red Hat states: "You never will buy a car without a dashboard...".  JON is the dashboard that you were missing for your car!  In this Webinar, you will discover how three different customers increased the return on their JBoss Enterprise Application Platform investment by using JON.

    Why coming from Brazil? It is not only because this country is in the media or because it is cool, but because Brazil typically has limited resources for deploying technology, so demonstrating how you can do more with less is critical in such an environment.  If it works here, then it can work for you as well!

    More info: https://inquiries.redhat.com/go/redhat/20100209ManagementWebinar

    When:

    Tuesday, February 9 | 2pm EST (GMT-5) / 19:00 GMT

    Tuesday, January 26, 2010

    The Opensource Marginal Cost

    Recently I had a nice discussion on Twtitter. The topic was opensource. I find it interesting a lot of people still believe that opensource is an ideology, or a development model. It is interesting too there are a lot of people who are trying to create new ways to define opensource, such as "Open source is a business tactic, not a business model"[1], I do not understand the problem in considering opensource a business model. Although I am an engineer, I have studied business administration and I am very comfortable with opensource as a "Business Model". Moreover, I believe that a "tactic" is based on some business model. So, I do not see the difference. As a result I will consider “business tactic” and “business model” as synonyms.





    Many of us are used to selling opensource to the "technical departments". But, of times when we are facing a top level management people, for various reasons, we have experience difficult in explaining opensource as a suitable alternative! One of the reasons for this difficulty is we are used to and prepared to explain opensource from technical perspective. But, our technical arguments are not well understood by many management types. Most management types understand business models, business strategies and business tactic, whichever you prefer to call them. That is not a “knock” against management types. They understand their domains just as engineers understand their technical domains. So, you can imagine the difficulty in management understanding the technical reasons for using open source. Likewise, you can imagine the difficulty engineers have in understanding some business models, strategies, tactics, etc.


    I think the question really comes down to, “How are CIOs and managers to trust in something, or rely on something, they do not fully understand from a business perspective or a technical perspective?” It is for this reason, I believe if we better positioned the business case and business reasons for using opensource as an alternative rather than using technical reasons, we would have a much better chance in convincing CIOs and managers opensource solutions can indeed reduce their cost and also provide benefits to their customers.


    In the study of economics there is a concept called "Marginal Costs"[2], In general terms, marginal cost at each level of production includes any additional costs required to produce the next unit. If producing additional vehicles requires, for example, building a new factory, the marginal cost of those “extra” vehicles includes the cost of the new factory. In practice, the analysis is segregated into short and long-run cases, and over the long run, all costs are marginal. At each level of production and time period being considered, marginal costs include all costs which vary with the level of production, and other costs are considered fixed costs. This is a concept that can by also applied into opensource industry.



    For JBoss Enterprise subscriptions, or any other product family, Red Hat has a cost to keep a number of employees contributing, testing, certifying, collaborating, writing documentation, training a support team, consulting team etc. For this reason, the"Opensource Marginal Cost" is really low. That's why Red Hat never charges expensive prices for their products. That is also one of the biggest advantages for any company who follows this kind of business model in order to create a really profitable company offering opensource solutions. Obviously, Red Hat receives many contributions, but any contribution must be certified, and supported by Red Hat. Tor this reason, even for collaborations, there is a cost to test and to provide the security that this contribution will not cause any damage to "Subscription Buyers". However, this cost is still low, compared to "Proprietary Software".

    "Opensource Marginal Cost" offers companies to save as much as 80% in the software acquisition.


    Industry will accept "opensource" when the advantages are tangible factors, and not only merely words of text. I cannot see any company keeping their doors open creating innovative solutions without a way sell them.

    In fact, I saw a huge company trying jump in the opensource market without a good plan, and the result turned out to be catastrophic. This particular company was acquired by another proprietary vendor. Some think this end result is a "proprietary win over the opensource". However, in fact, in my humble opinion this is a "strategic company win over a company with a poor opensource strategy ".


    I live into a country where a lot of companies are looking for ways to reduce their costs in software, not only because opensource is "a new trend", but because some of them must trim their “IT” budgets to make them more competitive. I have seen many companies who have reduced their cost of software licencing, and with the saved software licensing costs they offered their employees not only better salaries, but also better environments for employees to work in as well as additional training and incentives for education.


    Opensource is not only a way to develop software, it is a way to make employees happier by saving money which can then be invested in what is really relevant for the company, the employees!





    There are many others factos that shows how opensource is an alternative for the future, replacing the retrograde proprietary industry software, such as bio alternatives as true substitutes for gasoline and its derivatives. In the end, everything is economics. We must open our minds, and not only think just as engineers, but also begin to think in terms of long term business.


    Monday, January 18, 2010

    Introducing project: breakingwoods - Components Repository and resources for JBoss ESB

    Introduction


    First of all, the main objective of this project is to be a source of new ideas, resources, components and actions for JBoss ESB.  Nobody is interested in creating a fork (or anything like that), but we believe that it could be a nice way to contribute to the evolution of this incredible project, as well as to be an accurate information source and filter for candidate components to be integrated into the core JBoss ESB project.





    At breakingwoods, anybody will be able to contribute.  All contributions are welcome, whether that be a new ESB component, a review of an existing compoenent, ideas, fixes, testing etc... all will be really appreciated  The only thing you need is a Gmail/Google account.


    Freedom to Contribute


    Everybody at the breakingwoods's team believes that JBoss ESB is a very robust solution, but would be even better if we would add more Adapters, Listeners, Gateways (in JBoss ESB it might be the same), as well as new Actions. The same happened with another popular opensource ESB solution: Mule, made by MuleSource.  The Mule community has Mule Forge, which is an extension's repository for MuleESB.  We hope that breakingwoods can be exactly the same for JBoss ESB, offering lots of components, and showing valuable information about which new ideas are rocking or the most downloaded, rated, commented etc.





    Why this project is not hosted under JBoss.ORG?


    Firstly we would like to make the project strong in its own right.  Once it is hosted at Google, we hope people will feel comfortable enough to contribute with whatever they want, once it is not so close to the crowd and the spotlight. Nevertheless, maybe in the future, we could move from Google Code to JBoss.ORG.  This will depend of the success of this initiative.  Alternatively, it could be great to have it isolated.


    How can I contribute?


    There are several ways in which you can help to make this project a success:
    • To Propose / To Create / To Review/ To test: New Adapters/Gateways/Listeners
    • To Propose / To Create / To Review/ To test: New ESB Actions
    • To Propose / To Create / To Review/ To test: New Ideas, Designs, Quickstarts


    Already at breakingwoods:
    • esbgen:  A basic CLI tool similar to seam-gen.  Helps you create the first esb project.
    • TwitterAction:  Action for publishing an ESB Message in Twitter.
    • EMailListener:  Periodically polls in the configured e-mail account, publishing incoming emails to JBoss ESB as an ESB Message.
    • Google Spreadsheet Listener:  Connects to Spreadsheets hosted by GoogleDocs, publishing new records to JBoss ESB.
    •  Apache DBUtils:  Action that executes plain SQLs.


    There are new Actions and Listeners in the pipeline.  The following are some of the next Listeners we are planning.  Maybe you will be able to help:


    • Apache Camel Listener/ Action
    • SalesForce Listener / Action
    • Infinispan Listener/ Action
    • Terracota Listener / Action
    • AMQP Listener/Action
    • Where is yours ? :)


    We are working in some of these, so stay tuned, as lots of good things will appear here at this project.


    Another good point, is that most of these components will be compatible to JBoss SOA Platform.  Obviously Red Hat will not support problems regarding SalesForce, Terracota or anything that is not part of the JBoss SOA-P supported distribution.  However, you will still be able to add these components into your solutions, possibly reducing your development time and increasing your productivity.


    If you have chance, check it out here: http://code.google.com/p/breakingwoods/


    Enjoy one of the best things about open source development: "To learn with others essentially doing something useful".







    breakingwoods Team.

    Saturday, January 2, 2010

    JBoss ESB on the Google's Clouds: Spreeadsheet Listener

    Recently my brother started a new kind of service in his very small consultancy company, he is offering a kind of Consultancy over the Google Apps focused in small business customers, although I believe that Google Apps is not suitable just for small ones, but for bigger companies/clients as well.




    Google Apps offers lots of good functionalities and services, such as: a) E-Mail, b) Site, c) Agenda, d) Documents (An online Office suite). I believe that this is a good strategy, so you might face in a near feature people replacing the older Excel files by new Google Spreadsheets, and than I decide work on it a little bit, creating a new Gateway to interact with this Google Service.

    Getting Started with Google APIs

    Google offers a good documentation over their APIs[1], in fact, everything that Google does, you are able to interact with just using Java, Python or even JavaScript[2].

    You might use Google Spreadsheets for many purposes, since a basic data collecting, or as my friend JP Viragine told me: "Maybe we could use as a "Decision Table on the Clouds", or just a excel replacement. The big advantage, beyond the fact you don't need to install anything in your computer, is the "Collaboration", because you might share the online file with another people that will be able for editing any time and anywhere.

    Another big difference when we are handling such kind of technology is the simple fact that we are totally stateless, once the Http allows us connect, and after the processing the http will give an answer, and that's it, is not that easy we use "Observers/Observables" when we are talking about HTTP (by default Stateless protocol), so my strategy was use "Timers" for polling the http service. I had not found a way to receive a notification from the service using Java, maybe it would make my job easier.

    New JBoss ESB Listeners


    If you create your first JBoss ESB gateway, you will be able to create as much as you need! The only thing that I have to recall when I have to create a new Gateway/Listeners is the wiki section that Tom Fennelly wrote [3]. So everything you will see here in this entry is very well documented there, you must say thanks to Tom, he did a really good job documenting about this subject.


    JBoss ESB in Action with GoogleDocs

    The first step is declare our listener into Jboss-esb.xml, there we will describe everything we need, such as properties and its values as well as the Listener class itself:



    The most important configuration from this listener is the property: gatewayClass, which we are using: org.jboss.soa.jbossesb.gateways.google.GoogleDocsGateway , which is not an ou-of-the-box class from JBoss ESB, it is totally new, and you will see it working pretty soon. Moreover, we defined other properties that will be used by the Listener classes further, this properties are: documentName, feedURL, username, password and so on.

    I created a very ugly class GoogleDocsGateway, that for this entry is handling just the spreadsheet, this is a class that extends AbstractThreadedManagedLifecycle, after this the rest is quite easy. When you are extending this class, you must keep in mind that there are certain tasks to think about:

    1 -Define what you will do in the doInitialise() method, this is the method called when JBoss ESB invokes this service by the first time.

    2- The doRun() is the most important one, this is a method that or will be waiting for an event notification, or you must try get a way to poll the protocol that you are interacting with, in order to don't consume unnecessary resources.

    package org.jboss.soa.jbossesb.gateways.google;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    import org.jboss.soa.esb.ConfigurationException;
    import org.jboss.soa.esb.Service;
    import org.jboss.soa.esb.client.ServiceInvoker;
    import org.jboss.soa.esb.helpers.ConfigTree;
    import org.jboss.soa.esb.listeners.ListenerTagNames;
    import org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle;
    import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
    import org.jboss.soa.esb.listeners.message.MessageDeliverException;
    import org.jboss.soa.esb.message.Message;
    import org.jboss.soa.esb.message.format.MessageFactory;
    
    /**
     * Google Gateway Class
     * 
     * @author esilva
     */
    public class GoogleDocsGateway extends AbstractThreadedManagedLifecycle {
    
     private ConfigTree listenerConfig;
     private Service service;
     private ServiceInvoker serviceInvoker;
    
     private GoogleSpreadSheet sheet = new GoogleSpreadSheet();
    
     protected boolean firstExecution = true;
    
     public GoogleDocsGateway(ConfigTree config) throws ConfigurationException {
      super(config);
    
      this.listenerConfig = config;
    
      String serviceCategory = listenerConfig
        .getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
    
      String serviceName = listenerConfig
        .getRequiredAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
    
      service = new Service(serviceCategory, serviceName);
    
      sheet.setService(config.getAttribute("servicename"));
    
      sheet.setUsername(config.getAttribute("username"));
    
      sheet.setPassword(config.getAttribute("password"));
    
      sheet.setFeedurl(config.getAttribute("feedurl"));
    
      sheet.setDocumentName(config.getAttribute("documentname"));
    
     }
    
     @Override
     protected void doRun() {
    
      publishMessageToESB();
    
      int delay = 10000; 
      int period = 5000; 
      Timer timer = new Timer();
    
      timer.scheduleAtFixedRate(new TimerTask() {
       public void run() {
    
        try {
         if (sheet.hasChanges()) {
    
          System.out
            .println("Changes found, publishing the message again");
    
          publishMessageToESB();
    
         }
    
         else {
    
          System.out.println("No updates found");
    
         }
    
        } catch (Exception e) {
    
         e.printStackTrace();
        }
    
       }
    
      }, delay, period);
    
     }
    
     private void publishMessageToESB() {
      Message esbMessage = MessageFactory.getInstance().getMessage();
    
      try {
    
       esbMessage.getBody().add(sheet.load());
    
      } catch (Exception e) {
    
       e.printStackTrace();
      }
      try {
       serviceInvoker.deliverAsync(esbMessage);
    
      } catch (MessageDeliverException e) {
    
       e.printStackTrace();
      }
     }
    
     @Override
     protected void doInitialise() throws ManagedLifecycleException {
    
      try {
       serviceInvoker = new ServiceInvoker(service);
    
       sheet.initialize();
    
      } catch (MessageDeliverException e) {
    
       throw new ManagedLifecycleException(
         "Failed to create ServiceInvoker for Service listening Google Service: "
           + service + "'.");
      }
    
      catch (Exception e) {
    
       throw new ManagedLifecycleException(e);
      }
    
     }
    
    }
    
    
    

    I created a new class called: GoogleSpreadSheet, that is an abstraction over the tasks we must to do to interact with the Google Spreadsheets, and through the doRun() method I am using a kind of scheduler to poll the url of my spreadsheet according the property configuration made by the "user" of this gateway.

    package org.jboss.soa.jbossesb.gateways.google;
    
    import java.net.URL;
    import java.util.List;
    
    import org.quartz.Job;
    import org.quartz.JobExecutionContext;
    import org.quartz.JobExecutionException;
    
    import com.google.gdata.client.spreadsheet.SpreadsheetService;
    import com.google.gdata.data.spreadsheet.ListEntry;
    import com.google.gdata.data.spreadsheet.ListFeed;
    import com.google.gdata.data.spreadsheet.SpreadsheetEntry;
    import com.google.gdata.data.spreadsheet.SpreadsheetFeed;
    import com.google.gdata.data.spreadsheet.WorksheetEntry;
    
    public class GoogleSpreadSheet implements Job {
    
     protected static SpreadsheetService myService;
    
     protected URL metafeedUrl;
    
     protected SpreadsheetFeed feed;
    
     protected List spreadsheets;
    
     protected SpreadsheetEntry entry = null;
    
     private String service;
     private String username;
     private String password;
     private String feedurl;
     private String documentName;
     private String lastUpdate;
    
     protected boolean on = false;
    
     public String getService() {
      return service;
     }
    
     public void setService(String service) {
      this.service = service;
     }
    
     public String getUsername() {
      return username;
     }
    
     public void setUsername(String username) {
      this.username = username;
     }
    
     public String getPassword() {
      return password;
     }
    
     public void setPassword(String password) {
      this.password = password;
     }
    
     public String getFeedurl() {
      return feedurl;
     }
    
     public void setFeedurl(String feedurl) {
      this.feedurl = feedurl;
     }
    
     public String getDocumentName() {
      return documentName;
     }
    
     public void setDocumentName(String documentName) {
      this.documentName = documentName;
     }
    
     public String getLastUpdate() {
      return lastUpdate;
     }
    
     public void setLastUpdate(String lastUpdate) {
      this.lastUpdate = lastUpdate;
     }
    
     public GoogleSpreadSheet() {
    
     }
    
     public void initialize() throws Exception {
    
      myService = new SpreadsheetService(service);
    
      System.out
        .println("Initializing Connection between JBoss ESB and Google Docs...");
    
      myService.setUserCredentials(username, password);
    
      metafeedUrl = new URL(feedurl);
    
      feed = myService.getFeed(metafeedUrl, SpreadsheetFeed.class);
    
      spreadsheets = feed.getEntries();
    
      entry = null;
    
      for (int i = 0; i < spreadsheets.size(); i++) {
    
       entry = spreadsheets.get(i);
    
       if (entry.getTitle().getPlainText().equalsIgnoreCase(documentName)) {
    
        setLastUpdate(entry.getUpdated().toString());
    
       }
      }
    
     }
    
     public String load() throws Exception {
    
      StringBuilder builderOut = new StringBuilder();
    
      entry = null;
    
      for (int i = 0; i < spreadsheets.size(); i++) {
    
       entry = spreadsheets.get(i);
    
       if (entry.getTitle().getPlainText().equalsIgnoreCase(documentName)) {
    
        List worksheets = entry.getWorksheets();
    
        for (int j = 0; j < worksheets.size(); j++) {
    
         WorksheetEntry worksheet = worksheets.get(j);
    
         URL listFeedUrl = worksheet.getListFeedUrl();
    
         ListFeed listFeed = myService.getFeed(listFeedUrl,
           ListFeed.class);
    
         if (listFeed.getEntries().size() > 0) {
    
          StringBuilder header = new StringBuilder();
    
          for (String tag : listFeed.getEntries().get(0)
            .getCustomElements().getTags()) {
    
           header.append(tag + ",");
    
          }
    
          builderOut.append(header.toString().substring(0,
            header.lastIndexOf(",")));
    
         }
    
         for (ListEntry entrada : listFeed.getEntries()) {
    
          StringBuilder row = new StringBuilder();
    
          for (String tag : entrada.getCustomElements().getTags()) {
    
           row.append(entrada.getCustomElements()
             .getValue(tag)
             + ",");
    
          }
    
          builderOut.append(row.toString().substring(0,
            row.lastIndexOf(",")));
    
         }
        }
    
       }
    
      }
    
      return builderOut.toString();
    
     }
    
     public boolean hasChanges() throws Exception {
    
      SpreadsheetFeed feed = myService.getFeed(metafeedUrl,
        SpreadsheetFeed.class);
    
      List spreadsheets = feed.getEntries();
    
      entry = null;
    
      for (int i = 0; i < spreadsheets.size(); i++) {
    
       entry = spreadsheets.get(i);
    
       if (entry.getTitle().getPlainText().equalsIgnoreCase(documentName)) {
    
        if (getLastUpdate().equalsIgnoreCase(
          entry.getUpdated().toString())) {
    
         System.out.println(getLastUpdate() + "==========="
           + entry.getUpdated().toString());
    
         return false;
    
        } else {
    
         this.setLastUpdate(entry.getUpdated().toString());
         System.out.println("Changes arriving: " + getLastUpdate()
           + "===========" + entry.getUpdated().toString());
         return true;
    
        }
    
       }
    
      }
      return false;
    
     }
    
     public GoogleSpreadSheet(String service, String username, String password,
       String feedurl, String documentName, String lastUpdate) {
    
     }
    
     public String load(String service, String username, String password,
       String feedurl, String documentName, String lastUpdate)
       throws Exception {
    
      SpreadsheetService myService = new SpreadsheetService(service);
    
      myService.setUserCredentials(username, password);
    
      URL metafeedUrl = new URL(feedurl);
    
      SpreadsheetFeed feed = myService.getFeed(metafeedUrl,
        SpreadsheetFeed.class);
    
      List spreadsheets = feed.getEntries();
    
      SpreadsheetEntry entry = null;
    
      StringBuilder builderOut = new StringBuilder();
    
      for (int i = 0; i < spreadsheets.size(); i++) {
    
       entry = spreadsheets.get(i);
    
       if (entry.getTitle().getPlainText().equalsIgnoreCase(documentName)) {
    
        System.out.println("Last Update: " + entry.getUpdated());
    
        List worksheets = entry.getWorksheets();
    
        for (int j = 0; j < worksheets.size(); j++) {
    
         WorksheetEntry worksheet = worksheets.get(j);
    
         URL listFeedUrl = worksheet.getListFeedUrl();
    
         ListFeed listFeed = myService.getFeed(listFeedUrl,
           ListFeed.class);
    
         if (listFeed.getEntries().size() > 0) {
    
          StringBuilder header = new StringBuilder();
    
          for (String tag : listFeed.getEntries().get(0)
            .getCustomElements().getTags()) {
    
           header.append(tag + ",");
    
          }
    
          System.out.println(header.toString().substring(0,
            header.lastIndexOf(",")));
          builderOut.append(header.toString().substring(0,
            header.lastIndexOf(",")));
    
         }
    
         for (ListEntry entrada : listFeed.getEntries()) {
    
          StringBuilder row = new StringBuilder();
    
          for (String tag : entrada.getCustomElements().getTags()) {
    
           row.append(entrada.getCustomElements()
             .getValue(tag)
             + ",");
    
          }
    
          System.out.println(row.toString().substring(0,
            row.lastIndexOf(",")));
          builderOut.append(row.toString().substring(0,
            row.lastIndexOf(",")));
    
         }
        }
    
       }
    
      }
      return builderOut.toString();
    
     }
    
     @Override
     public void execute(JobExecutionContext ctx) throws JobExecutionException {
    
      try {
       System.out.println("Has Changes: " + this.hasChanges());
      } catch (Exception e) {
    
       e.printStackTrace();
      }
    
     }
    
    }
    
    
    

    Instead to use lots of confusing images, I will use a screencast:



    I hope you liked that idea, and you can feel yourself more comfortable for creating new Listeners/Gateways for JBoss ESB.


    Rerefences

    [1] - http://code.google.com/intl/pt-BR/apis/spreadsheets/
    [2] - http://code.google.com/intl/pt-BR/apis/spreadsheets/data/3.0/developers_guide_java.html
    [3] - http://community.jboss.org/docs/DOC-13193

    Tuesday, October 6, 2009

    Enabling BPEL into JBoss : Welcome to the Riftsaw Project

    The objective of Riftsaw Project is to bring BPEL capabilities for JBoss Application Server. This project is build on top of Apache ODE, basically adding some features for JBoss App Severs as which will allow either JBoss ESB (Community based) and in the future JBoss SOA Platform(Enterprise SLA) to support BPEL out-of-the-box.


    Another "Opensource" BPEL alternative


    If anybody tell you that BPEL is an easy language to create the processes manually and if you believe, you are ready to believe in any tale! I tell you it because this is a kind of technology that you really need a graphical tool/designer.


    The JBoss Community has adopted for many years the Eclipse to deliver JBoss Tools and now this set of plugins made by JBoss Team is already integrated with Eclipse BPEL Designer. This is a cool plugin and you will really need this feature into your Eclipse, otherwise create any simple BPEL process will be a really boring task.

    Nevertheless we support BPEL Designer in JBoss Tools. You are able to use the NetBeans BPEL Desginer which is another really cool opensource alternative. I did some personal researching over BPEL support in NetBeans and it was a real good experience. For certain moments I thought that Eclipse could incorporate some ideas from NetBeans designer as well.

    I recommend you install the JBoss Tool's 3.1.0.M3 plugins into your Eclipse 3.5 (Galileo). It will add the BPEL support into your Eclipse as well as the capacity to deploy the process besides editing the WSDLs visually. For more information about this see this link: https://www.jboss.org/tools/download/dev.html

    Once you are aware that you really need a designer tool, let's try share with you some good information before you dive into BPEL Development; first of all there are certain resources and concepts that would make BPEL easier for every human. These are the following:
    • WSDL
    • XPath
    • XSLT
    • XML Schema
    If you have a good background over those items above, BPEL will be incredibly easier for you, otherwise, I recommend you attend the "Webservices online training", this is one of the training offered in JavaPassion Website. In this training, you will have some good brief introductions about everything you need to be a BPEL Rock Star.

    I've been listen many many times companies complaining about SOA Adoption independently of the technology vendor a very common problem is what I call: "The gap between processes and the bussiness components". This is the moment where your company spent thousands of US$ to discovery the company's processes. So many Six Sigma guys came to you company and told you everything that your company is doing wrong and **designed some proposals using BPMN** or any other notation of "How the company could/must work". At this moment you can see a huge interrogation in front of you while you are trying to figure out which glue you will use to put your processes working with your legacy COBOL, Java, .Net and a bunch of WebServices representations of these legacy components, have you think about that before?

    BPEL could help you in 30% to 40% to solve these kind of problems. Once BPEL aims you think in "Composite Applications" which in general are many compositions of different services (keep in mind that it can be not only WebServices).


    This technology is perfect when you must execute several services according some conditions or even some rules. BPEL allows you think in "Services Orchestration" at the same way you think when you are creating Swing UI using some graphical designer.

    The RiftSaw/Apache ODE is an implementation of WS-BPEL 2.0 which is the newest specification definied by OASIS of the standard BPEL4WS (Business Process Execution Language for Web Services) 1.0 and 1.1. Red Hat counts with one contributor for this spec: Alejandro Guízar (JBoss, by Red Hat).

    Thinking about Processes

    I married about 1 year and I can still remember my wedding process. Several people were involved. A lot of parallel tasks, a lot of dependent tasks, timeouts, authorizations, rules etc! Now try imagining everything into a flow keeping in mind how you would organize your plans to get married and keep in mind that you have a lot of expecations, and everything must be perfect on time, saving costs and allowing everybody to be happy... Well, this is exactly what processes are trying to solve and provide to the companies globally speaking!


    A Process is composed by a Sequence of many activities and those different activities can to perform particular actions, but always promoting a collaborating among them. Let's see some examples of this:

    Getting Married Process -> Propose the Lady -> Request Parent's Authorization -> Organize the Party -> Invite People -> Organize Honey Moon -> Organize Bachelor Party -> Say Yes!


    If everything in the sequence flow is true, congratulations, you will have a good chance to celebrate a nice wedding! Although a process must handle when something that you are not expecting to happen, for instance: "Bachelor Party denied", and than you might try several different actions, flows or even new sequences for it. :)

    WS-BPEL 2.0 spec describes a process, the sequence, the activities that are part of , the faults, the exceptions, the alternative paths and everything you need to create a process.

    Using JBoss technologies for BPEL

    When we are working with BPEL, basically the majority of Tools generates a .bpel file, this is a XML File that describes the process itself. A BPEL Process represents several interations with a bunch of Webservices, then if the BPEL can invoke several WebServices, makes sense if the way to invoke a BPEL process execution would a WebService as well, for this reason each .bpel file, or process, will have a WSDL that will represent the Client invocation, as well as the response that will send after the process flow.

    A BPEL Process is a sequence of activities inside some sequence, exactly as I said before, you may represent it graphically(IDEs) or programatically (XML), the following table will show the 2 action's categories :












    Basic
    Activities

    Structured
    Activities



    • invoke

    • receive

    • reply

    • assign

    • compensate

    • compensateScope

    • empty

    • exit

    • throw

    • rethrow

    • validate

    • wait





    • flow

    • forEach

    • if

    • pick

    • repeatUntil

    • scope

    • while






    These activities are represented in the BPEL Palette, as you can see in the following image:

    This is a simple blog entry, so it would be impossible describe BPEL in depth here. So I recommend you read some books and deeper BPEL Articles if you need more background on this technology. it will make you understand this entry much better.

    Creating your first BPEL Project using JBoss Tools, RiftSaw and JBoss App Server 5.1

    First of all you must have in your machine the following software:

    * Eclipse 3.5 + JBoss Tools 3.1.0M3
    * JBoss 5.1.0 GA
    * JBoss Riftsaw M1

    Installing Riftsaw

    This came from README.txt:

    The build.xml script in this directory is responsible for deploying the BPEL runtime and deployer to the JBoss AS,and the BPEL/ESB examples to the JBossESB environment.

    1) Install JBoss5.1.0.GA and JBossESB4.6.GA, and follow the JBossESB instructions for installing it into JBossAS

    2) Update the deployment.properties file to set the path to each of this installations

    3) Run "ant deploy" to install the BPEL deployer and engine into the JBossAS

    4) Start the JBossAS server

    At this point, you can try out the examples in the RiftSaw/samples folder.

    Alternatively, if you want to try out the BPEL/ESB examples, then:

    6) Run "ant deploy-esb-examples" to copy the ESB/BPEL examples into the JBossESB samples.

    7) Follow the $JBossESB/samples/quickstarts/webservice_esb_bpel instructions to run the example

    One thing that you may ask yourself:

    a) Why the Riftsaw is installed both in AppServer and the ESB Server ?
    - Hide quoted text -

    A: In my point of view you may think into a "process repository" or something like other vendors loves to call : "A process server", so the BPEL processes will be running into an exclusiv (or clustered or load balanced) instance of a JBoss AppServer, which will host the Riftsaw Engine, as well as the WSDLs that represents the processes.

    In another hand you have the other part of your SOA solution, in that case in particular I am talking about an ESB! At this moment, JBoss ESB can host services that may put several BPEL processes to work together, for each BPEL Process you will have an 1-1 relation with a WSDL, once you will access a BPEL process of the same way you acess a regular WebService: Through an WSDL.

    Depending of what you wanna do in terms of Orchestration you may count just with BPEL, however keep in mind that you will be limited into WSDL boundary, so if you need different protocols collaborating with each other

    Now I will save your time! it's time to watch this tutorial to get some basics of BPEL Development using JBoss Tools + Riftsaw, click here to watch!

    If you prefer, you may watch it here:

    JBoss Riftsaw - Getting Started Tutorial from Edgar Silva on Vimeo.



    Why is it useful? It shows how you can edit the WSDL that acts as the endpoint for the BPEL process, and also shows how you can create the Service, Ports, Bind for this WebService.

    Thursday, September 17, 2009

    Screencast: Making JBoss ESB listen XMPP Protocol using Smack API

    This simple screen-cast will show you how JBoss ESB can listen XMPP messages.

    For this solution, I used Openfire+Smack API + JBoss ESB + Pidggin (could be any Gtalk client, Adium or so on):



    I hope you enjoy, forgive my accent ( easl - English as Second Language) and see how you can add new capabilities into JBoss ESB

    Any comment, doubt or questions, feel you free to reach me at edgar.silva (at) redhat.com

    Wednesday, July 29, 2009

    Would you like to hear about JON's success cases as well as a curious accent at JBossWorld 2009?

    This September is very special for me, my wife and my dad will be celebrating their birthday this month, and the third motivation for happiness is the fact to be speaking at JBossWorld, and sharing some thoughts and our experiences with everybody there.



    This JBossWorld 2009, you will have chance to watch a presentation of some success cases of JBoss Operations Network (JON) in Brazil, and also notice how some customers obtained very valuable benefits from this product.

    The presentation title is: The "bossanova-way": JBoss management with JON in Brazil - Real case studies and applications of JBoss Operations Network , you may ask: "wth...does Bossanova mean in this context?".
    Well, I'm gonna tell you the inspiration behind this title, Bossanova is a brazilian style of music very well known internationally speaking, I have seen many docus on TV saying that bossanova is a very appreciated and recognized as a sophisticated form of entertainment in the US. However, many of my american friends, have no idea that it comes from Brazil...
    I am not sure if you like Frank Sinatra, but he is one of the persons that fell in love by this music style?



    Perhaps you are very used to hearing good stuff about Brazil such as soccer, samba, beaches....and ok...Ladies.... but many people don't realize that Red Hat brought JBoss business to Brazil 3 years ago, and we could make JON a "defacto" solution for majority of the JBoss Enterprise's subscription buyers.


    And our secret...our secret was somewhat based on bossanova, as far as we tried to be: "Simple, however sophisticated", helping people understand the value and benefits that JON can bring to the companies that are using JBoss in an enterprise environment.

    In this presentation, we will show some testimonial of customers, as well as some technical demos and simulation of the key features that were mandatory for running and support JBoss in a very enterprise level. Yep...We will have deep demos, besides a rare accent.

    Well, I hope to see you there, in the end I am sure that you will see the power of JON in very large interesting applications and scenarios in the country where Brazilian Portuguese is spoken :)

    Wednesday, June 10, 2009

    JBoss AOP in a Real World scenario

    See the following statement:

    " Tell me what is happening between your Application Server and your Database"


    AOP is not something really new, besides you can use AOP for many real scenarios nowadays, like the proposed above, so, lets do it.
    Installing JBoss AOP distro in your JBoss AppServer

    Download the latest JBoss AOP binary, unzip this in your hard disk, in the jboss-aop folder, you have 2 options for updating, one for JBoss 4.x and other for 5.x.
    • /jboss-aop-2.1.1.GA/jboss-40-install/jboss-aop-jdk50.deployer or
    • /jboss-aop-2.1.1.GA/jboss-50-install/jboss-aop-jdk50.deployer
    Both contains a build.properties, which you must edit it and inform the following properties:
    • jboss.home= put here your App Server directory home
    • jboss.config= put here the profile which you will update the AOP capabilities (eg: aop)
    In your shell, in the appropriated deployer installer dir, you will call the "ant " command, it will update your JBoss Profile.
    Enabling AOP in your JBoss Profile

    In your profile, in the folder $jboss_home/$profile/deploy/jboss-aop-jdk50.deployer/META-INF, you will edit the file jboss-service.xml , will change the EnableLoadtimeWeaving attribute to true, according the following image:

    After you change the AOP service, you must copy to the bin directory of your JBoss, the jar file called pluggable-instrumentor.jar that is in the lib folder of your JBoss AOP home directory.

    The last step, you must add the following parameter in the JAVA_OPTS in the run.conf file:

    -javaagent:pluggable-instrumentor.jar

    Done, your AOP is updated in your JBoss AppServer.

    Intecepting every JDBC Call made from your AppServer

    JBoss AOP is an AOP Framework, which combined with AppServer make this kind of task really easy, where once you have a .aop file, it is a "deployable" file, that JBoss will deploy and make our aspects live in the App Server.

    We will create a simple Interceptor, which is a simple class that implements org.jboss.aop.advice.Interceptor , that everything we need, is present , see the following source code:

    public class JDBCMetricInterceptor implements Inteceptor {
    
    public JDBCMetricInterceptor() {
    
    }
    
    public Object invoke(Invocation invocation) throws Throwable {
    
    StringBuilder builder = new StringBuilder();
    try {
    builder.append("\n\t============== JDBC CALL ===============");
    
    
    if (invocation instanceof MethodInvocation) {
    MethodInvocation mi = (MethodInvocation) invocation;
    builder.append("\n\ttype: Method Invocation");
    builder.append("\n\tmethod: " + mi.getMethod().getName());
    
    Object[] args = mi.getArguments();
    
    if (null != args && args.length > 0) {
    
    builder.append(String.format("\n\tHey, I saw %s parameter(s)",
    args.length));
    for (Object object : args) {
    builder.append(String.format(
    "\n\tParameters sent: %s of %s",   object,  (null==object)? "Null parameter": object.getClass().getName()));
    
    }
    
    }
    
    
    }
    
    return invocation.invokeNext();
    } finally {
    builder.append("\n\tJDBC Invocation end");
    builder.append("\n\t========================================");
    logger.info(builder.toString());
    }
    }
    
    }
    
    


    First of all, you might think: "We can intercept the java.sql.Statement class... and that's all", but JBoss AOP can't do that with "Java Standard Classes". So we will define a "definition" that our target will be: "Every class inside the package of the HSQLDB driver , which is org.hsqldb.jdbc, besides these classes must implement the class java.sql.Connection, which we assume that will execute the SQL to the database", right? See the code of the jboss-aop.xml file:

    
    
    *(..))">
    
    
    


    Once you deploy the generated aop file, when you boot the AppServer, you will see the AOP logging our messages:

    Ofcourse, create anything with JBoss AOP is easier when we have in Brazilian office some help from Flavia Rainone, thanks Flavia.

    Have fun with AOP, and keep in mind that you may use that in many real scenarios, is not necessary to be so geek for find out some opportunity to use it.

    Thursday, April 2, 2009

    Smooks+JBoss ESB applied : Getting Quotes from YahooFinance

    I've been doing some researching for creating a cool sample using CEP into JBoss, while I am still working on it, I decided put a simple sample using Smooks for transforming CSVs from Yahoo Finance into XMLs, which is a format much easier for integrating with everything else.

    Getting Stock Symbols and Quotes from Yahoo Finance in CSV Format


    Yahoo offers an URL that gives you information about the quotes, it is not a WebServices, "REST Service" or nothing especial or too complex, it is basically an HTTP URL, that you may pass some additional info, and you can see the Quotes information by a glimpse into a CSV output. Look the following URL format:

    http://finance.yahoo.com/d/quotes.csv?s= a BUNCH of STOCK SYMBOLS separated by "+" &f=a bunch of special tags

    These special tags you can get more information here

    I decided use this URL: http://finance.yahoo.com/d/quotes.csv?s=RHT+MSFT+ORCL+JAVA&f=snb3pt1d1 , and what does these parameters means?

    a) s= The symbols, in that case: Red Hat, Microsoft, Oracle and Sun Microsystems.

    b) f= It means which information I wanna in my "report", I decided put:
    • s = symbol s - symbol
    • n- companyName
    • b- bid
    • 3p - last bid
    • t1 - time
    • d1 - TradeDate
    The result will give me the following information:

    [java] "RHT","RED HAT INC",17.90,17.68,"4:04pm","4/2/2009"
    [java] "MSFT","Microsoft Corpora",19.33,19.31,"4:00pm","4/2/2009"
    [java] "ORCL","Oracle Corporatio",18.83,18.58,"4:00pm","4/2/2009"
    [java] "JAVA","Sun Microsystems,",8.38,8.00,"4:00pm","4/2/2009"

    Time to make it available into my JBoss ESB.

    Using Smooks

    The only thing that I am doing for testing is send the data obtained from the Yahoo URL to my Service JMS Quee Gateway, you may use Commons Http Client if you want something more sophisticated, othewise you may create a simple code as you can see in the following code-listing:


    public static void main(String args[]) throws Exception
    {
    SendJMSMessage sm = new SendJMSMessage();
    sm.setupConnection();
    StringBuilder quotesData = new StringBuilder();
    try {
    // Create a URL for the desired page
    URL url = new URL("http://finance.yahoo.com/d/quotes.csv?s=RHT+MSFT+ORCL+JAVA&f=snb3pt1d1");

    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str;
    while ((str = in.readLine()) != null) {

    quotesData.append(str + "\n");


    }
    in.close();
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }

    System.out.println("Sending:\n" + quotesData.toString());
    sm.sendAMessage(quotesData.toString());
    sm.stop();

    }





    This is a basic JMS client (use the quickstarts as a template).

    Now, the only I thing I have to do is configure my smooks-res.xml file as well as my "Smooks Actions" in jboss-esb.xml, in the following image, you can see on the left side the jboss-esb.xml and smooks-res:


    The only thing I had done was editing some XML, and everything is ready.

    This is one more practical example of JBoss ESB and its transformation engine.

    Download the solution

    You can download the solution from here

    Tuesday, February 24, 2009

    A Simple RestEasy Maven Archetype

    I've been looking for better and faster ways to develop some of my solutions, while Gradle is quite promising in my opinion, I still prefer Apache Maven for collaborative projects, even Ant sounds good when you can predict any scenario for your application/project.

    I had searching a lot about a RestEasy Archetype, but I haven't found. RestEasy is a project which Maven is strongly used, although I am not sure if I did my search properly, but just in case I create a simple RestEasy Archetype, which you can download from here.

    Once you have Maven installed and configured, you just will unzip this zip file, and will type mvn install. You will see the following results into your console:

    [INFO] [jar:jar]
    [INFO] [install:install]
    [INFO] Installing /Users/edgarsilva/redhat/dev/NetBeansProjects/resteasy-archetype/target/resteasy-archetype-1.0-SNAPSHOT.jar to /Users/edgarsilva/.m2/repository/org/jboss/resteasy/resteasy-archetype/1.0-SNAPSHOT/resteasy-archetype-1.0-SNAPSHOT.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Wed Feb 25 04:26:00 BRT 2009
    [INFO] Final Memory: 9M/16M
    [INFO] ------------------------------------------------------------------------
    edgar-silvas-macbook:resteasy-archetype edgarsilva$


    Now, you are ready to create RestEasy projects using Maven Archetypes, to do that, you can use your preferred IDE or just can type in the console for instance, the following command:

    mvn archetype:create -DarchetypeVersion=1.0-SNAPSHOT -Darchetype.interactive=false -DgroupId=sample -DarchetypeArtifactId=resteasy-archetype -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.jboss.resteasy -DartifactId=sample

    This command, will create a project called "sample" which contains everything you need for developing and deploying RestEasy Applications into JBoss Application Server.

    In the following image, you can see the project opened using NetBeans:


    If you run mvn:install you will see Maven in action downloading everything required for building your project. In addition, this archetype includes JBoss AppServer tasks, which you can use for deploying, starting or stooping the server anytime you want. After typing mvn install, this goal will compile and generated a war file into target folder, however you may call the command mvn jboss:start that you will see the following output:

    [jsilva@jsilva esresteasy]$ mvn jboss:start
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'jboss'.
    [INFO] artifact org.codehaus.mojo:jboss-maven-plugin: checking for updates from central
    [INFO] ------------------------------------------------------------------------
    [INFO] Building esresteasy
    [INFO] task-segment: [jboss:start]
    [INFO] ------------------------------------------------------------------------
    [INFO] [jboss:start]
    [INFO] Starting JBoss...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1 second
    [INFO] Finished at: Wed Feb 25 16:30:56 BRT 2009
    [INFO] Final Memory: 3M/74M
    [INFO] ------------------------------------------------------------------------
    [jsilva@jsilva esresteasy]$


    Not only starting JBoss AppServer, you are also able to deploy your application using the command: mvn jboss:deploy :

    [jsilva@jsilva esresteasy]$ mvn jboss:deploy
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'jboss'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building esresteasy
    [INFO] task-segment: [jboss:deploy]
    [INFO] ------------------------------------------------------------------------
    [INFO] [jboss:deploy]
    [INFO] Deploying /opt/java/workspace/esresteasy/target/esresteasy.war to JBoss.
    [INFO] No server specified for authentication - using defaults
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2 seconds
    [INFO] Finished at: Wed Feb 25 16:39:41 BRT 2009
    [INFO] Final Memory: 3M/74M
    [INFO] ------------------------------------------------------------------------



    If you look the JBossApp Server console you can see your project deployed into JBoss:

    16:39:39,812 INFO [TomcatDeployment] deploy, ctxPath=/esresteasy, vfsUrl=
    16:39:39,930 ERROR [STDERR] 52 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider DataSourceProvider
    16:39:39,935 ERROR [STDERR] 57 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider DefaultTextPlain
    16:39:39,936 ERROR [STDERR] 58 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.StringTextStar
    16:39:39,937 ERROR [STDERR] 59 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.InputStreamProvider
    16:39:39,939 ERROR [STDERR] 61 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.ByteArrayProvider
    16:39:39,941 ERROR [STDERR] 63 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider
    16:39:39,942 ERROR [STDERR] 64 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider
    16:39:39,944 ERROR [STDERR] 66 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Added built in provider org.jboss.resteasy.plugins.providers.StreamingOutputProvider
    16:39:39,950 ERROR [STDERR] 72 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.providers - Adding built in provider org.jboss.resteasy.plugins.providers.IIOImageProvider
    16:39:40,084 ERROR [STDERR] 206 [http-127.0.0.1-8080-1] INFO org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - Adding scanned resource: esresteasy.Hello
    16:39:40,087 INFO [STDOUT] FOUND JAX-RS resource: esresteasy.Hello



    I am looking for an easy way to pass information of some users inputs to fill some information into my pom.xml, the same strategy used in seam-gen for instance and also in esb-gen, but I am still looking for how to do that.

    Seems that Maven Archetype is changing or moving for a next generation (http://docs.codehaus.org/display/MAVEN/ArchetypeNG) , hopefully the actual archetypes are still working fine.