Wednesday, July 22, 2009

Integrating Apache ActiveMQ with WSO2 ESB

When going through some of the recent posts in the WSO2 ESB user forum, I got the impression that some folks are having trouble getting Apache ActiveMQ to work with WSO2 ESB. So today I'm going to explain how to integrate Apache ActiveMQ with WSO2 ESB and run one of the JMS sample scenarios.

I will be using WSO2 ESB 2.1 and Apache ActiveMQ 5.2. First download WSO2 ESB 2.1 and Apache ActiveMQ 5.2 from the respective websites if you already haven't done so. Apache ActiveMQ has different distributions for Windows platform and Unix/Linux platform. So remember to download the distribution that matches your target platform. To run the sample scenario described here you will also require Apache ANT. Once you have extracted the downloaded archives to some location in your local disk. Let's refer to WSO2 ESB installation directory as ESB_HOME and ActiveMQ installation directory as AMQ_HOME.

Now we are all set to go.....

First go to AMQ_HOME/bin directory and start the ActiveMQ broker. On Linux you simply have to execute the script named 'activemq'.

Then you need to copy the following 3 jar files into ESB_HOME/repository/components/lib directory. (With WSO2 ESB 2.1 this is the location where most of the 3rd party dependencies should be deployed)
  • activemq-core-5.2.0.jar
  • geronimo-j2ee-management_1.0_spec-1.0.jar
  • geronimo-jms_1.1_spec-1.1.1.jar
You will find all these jars in AMQ_HOME/lib directory.

Then open up ESB_HOME/conf/axis2.xml file in your favorite text editor and uncomment the JMS listener configuration. JMS listener configuration should look something like this.

<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<parameter name="myTopicConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">
org.apache.activemq.jndi.ActiveMQInitialContextFactory
</parameter>
<parameter name="java.naming.provider.url" locked="false">
tcp://localhost:61616
</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">
TopicConnectionFactory
</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
</parameter>

<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">
org.apache.activemq.jndi.ActiveMQInitialContextFactory
</parameter>
<parameter name="java.naming.provider.url" locked="false">
tcp://localhost:61616
</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">
QueueConnectionFactory
</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>

<parameter name="default" locked="false">
<parameter name="java.naming.factory.initial" locked="false">
org.apache.activemq.jndi.ActiveMQInitialContextFactory
</parameter>
<parameter name="java.naming.provider.url" locked="false">
tcp://localhost:61616
</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">
QueueConnectionFactory
</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
</parameter>
</transportReceiver>
Now go to ESB_HOME/bin and start sample 250 which demonstrates how to receive messages over JMS and forward them over HTTP. To start the sample go to ESB_HOME/bin and run the command ./wso2esb-samples.sh -sn 250 if you are on Unix/Linux or run the command ./wso2esb-samples.bat -sn 250 if you are on Windows. This will bring up WSO2 ESB with sample 250 configuration.

The ESB startup may take some time depending on your system. However note the following lines on the console when it starts up.
INFO - JMSConnectionFactory JMS ConnectionFactory : myTopicConnectionFactory initialized
INFO - JMSConnectionFactory JMS ConnectionFactory : myQueueConnectionFactory initialized
INFO - JMSConnectionFactory JMS ConnectionFactory : default initialized
INFO - JMSListener JMS Transport Receiver/Listener initialized...
This confirms that the JMS transport has successfully started by connecting to the ActiveMQ broker. When the ESB has fully started up you should get a message similar to the following line on the console.
INFO - StartupFinalizerServiceComponent WSO2 Carbon started in 33 sec
Now we are ready to run the sample. Go to ESB_HOME/samples/axis2Server/src/SimpleStockQuoteService and run the command ant to build the sample service and deploy in the sample Axis2 server that comes with WSO2 ESB (This is where you need Apache ANT. So make sure you have properly installed ANT before trying to build the service and proceed any further.). Then switch back to ESB_HOME/samples/axis2Server and start the sample server by running axis2server.sh or axis2server.bat startup script.

Finally to run the sample client head over to ESB_HOME/samples/axis2Client directory and run the following command.
ant jmsclient -Djms_type=pox -Djms_dest=dynamicQueues/StockQuoteProxy -Djms_payload=MSFT
This will send a message to a JMS queue named StockQuoteProxy. The ESB will receive the message from the queue and forward it to the sample Axis2 server over HTTP. When the Axis2 server is done with processing the message it will print the following line on the console.
samples.services.SimpleStockQuoteService  :: Accepted order for : 9351 stocks of MSFT at $ 158.6569470528259
Congratulations! You just got Apache ActiveMQ integrated and working with WSO2 ESB. Now that wasn't too hard, was it? The key thing you have to remember is the way 3rd party dependencies are deployed into WSO2 ESB. In older versions of WSO2 ESB you had to copy the jar files into ESB_HOME/lib. But that does not work with the latest version of WSO2 ESB. The deployment model of WSO2 ESB has slightly changed with the introduction of WSO2 Carbon and Equinox P2 into the ESB.

So that's all about getting ActiveMQ to work with WSO2 ESB. With this knowledge now you may try other JMS related samples that come with WSO2 ESB.

Wednesday, July 15, 2009

Head First Security in SOA

No, O'Reilly Media hasn't published a book on 'Security in SOA' in their world famous Head First series (at least not that I know of). This post is about a wonderful presentation on the above mentioned subject, conducted by Prabath SiriWardena, couple of weeks back at the WSO2 Summer School. Prabath is one of my colleagues at WSO2 and he is one of the most experienced folks we got. Prabath's expertise is on computer security and at WSO2 he leads all security related projects including WSO2 Identity Server. In this summer school presentation Prabath has started simple, by explaining the fundamental concepts of computer security like confidentiality, integrity and availability and goes on to more complex topics such as public key cryptography, transport level and message level secuity, WS-Security specs and Username-Token authentication. He gives a glimpse on various options available to SOA architects and Web Service authors to secure their applications at different levels while emphasizing on the importance of interoperability.
Throughout the presentation he has kept things simple yet extremely interesting. You will find the entire presentation sort of follows the storyline based, fun-filled teaching method which is a very effective technique commonly used in the books of the Head First series (and hence the title).
If you want to learn the fundamentals of Security in SOA and how it is used in the enterprise (or how it should be used in the enterprise), this presentation would be a great starting point. So start flipping through the slides now and see for yourself.

View more documents from wso2.org.

Sunday, July 12, 2009

Amplify Your SOA with WSO2 ESB 2.1

If you have been following my blog, then you already know that WSO2 Carbon 2.0 and a host of other Carbon based WSO2 SOA products were released last week. WSO2 Enterprise Service Bus 2.1, which is one of the released products, must be highlighted as a high quality, feature rich and extremely user friendly piece of SOA middleware for a number of reasons. Like all its predecessors, this version of WSO2 ESB is also based on Apache Synapse, the lightweight, ultra-fast ESB. WSO2 ESB is generally popular among SOA enthusiasts because of the following set of key features provided by the ESB.
  • Proxy services - facilitating synchronous/asynchronous transport, interface (WSDL/Schema/Policy), message format (SOAP 1.1/1.2, POX/REST, Text, Binary), QoS (WS-Addressing/WS-Security/WS-RM) and optimization switching (MTOM/SwA).
  • Non-blocking HTTP/S transports based on Apache HttpCore for ultrafast execution and support for thousands of connections at high concurreny with constant memory usage.
  • Built in Registry/Repository, facilitating dynamic updating and reloading of the configuration and associated resources (e.g. XSLTs, XSD, WSDL, Policies, JS, Configurations ..)
  • Easily extendable via custom Java class (mediator and command)/Spring mediators, or BSF Scripting languages (Javascript, Ruby, Groovy, etc.)
  • Built in support for scheduling tasks using the Quartz scheduler.
  • Load-balancing (with or without sticky sessions)/Fail-over, and clustered Throttling and Caching support
  • WS-Security, WS-Reliable Messaging, Caching & Throttling configurable via (message/operation/service level) WS-Policies
  • Lightweight, XML and Web services centric messaging model
  • Support for industrial standards (Hessian binary web service protocol/ Financial Information eXchange protocol and optional Health Level-7 protocol)
  • Enhanced support for the VFS(File/FTP/SFTP)/JMS/Mail transports with optional TCP/UDP transports and transport switching for any of the above transports
  • Support for message splitting & aggregation using the EIP and service callouts
  • Database lookup & store support with DBMediators with reusable database connection pools
  • WS-Eventing support with event sources and event brokering
  • Rule based mediation of the messages using the Drools rule engine
  • Transactions support via the JMS transport and Transaction mediator for database mediators
  • Internationalized GUI management console with user/permission management for configuration development and monitoring support with statistics, configurable logging and tracing
  • JMX monitoring support and JMX management capabilities like, Gracefull/Forcefull shutdown/restart
Wow! That's a lot of features for a software product developed openly and distributed free of charge under Apache Software License 2.0. As you would imagine, it is mainly the performance and the lightweight operation model of WSO2 ESB which makes it stand out from the rest. In addition to the above mentioned key features the latest ESB 2.1 release brings you the following set of new features.
  • Rule based mediation via Drools
  • Fine grained authorization for services via the Entitlement mediator
  • Reliable-Messaging specification 1.1 support
  • Enhanced WS-Eventing support and Event Sources making it an even broker
  • Enhanced AJAX based sequence, endpoint and proxy service editors
  • Enhanced transport configuration management through the graphical console
  • Enhanced integrated registry and search functionalities with versioning, notifications, rating of resources, and commenting
  • Enhanced remote registry support
  • Default persistence to the registry for the configuration elements
  • Enhanced permission model with the user management
  • Enhanced REST/GET and other HTTP method support
  • P2 based OSGi feature support, for optional features like service management, runtime governance
The coolest thing about WSO2 ESB 2.1 is that it is 100% OSGi based (thanks to the Carbon platform of course!). All the features are packed into OSGi bundles and therefore adding new features and removing unnecessary features cannot get any easier. The newly introduced provisioning support based on Equinox P2 makes it particularly easy to deploy new features and third party libraries into the ESB. With WSO2 ESB 2.1, you can deploy only the features you want and only them. You are not forced to load any features/libraries that you never use. Why waste memory and other resources on features never used, right?
With ESB 2.1 registry integration support has improved vastly. WSO2 ESB 2.1 comes with an embedded WSO2 G-Reg instance but you can easily point the ESB to a remotely hosted registry instance in a matter of seconds. ESB 2.1 also has the ability to export its entire configuration to the registry and reload the configuration back from the registry at the server startup.
User interfaces and context sensitive help system have gone through lot of rework. You will find that most of the web interfaces are now fully AJAX compliant making it easy and fun to work with WSO2 ESB. All UIs are fully internationalized and can be even separated from the backend system to be hosted as different web application.
WSO2 ESB 2.1 is a giant step forward by the WSO2 folks to make their ESB even more elegant and enterprise ready. It gives you a combination of high performance, modularity and user friendliness. It is completely free and open source, with a very active and supportive community of developers to back up all the development work. WSO2 also offers user training, development support and production support to any party which requires such facilities.
If you are looking for a robust mediation solution to power your enterprise SOA or if you are tired of trying out expensive proprietary ESB solutions, it’s high time you give WSO2 ESB 2.1 a spin. It will be totally worth it!!!

Friday, July 10, 2009

WSO2 Carbon Platform Takes Another Giant Step Forward

Weeks have passed by since I did my last blog post. The reason for my prolonged silence in the blog sphere was due to the fact that I was working hard on a very important point release of WSO2 Carbon 2.0 and a host of WSO2 Java products based on the Carbon platform. Ideally these releases should have come out bit early but realizing the importance of implementing some new features, we decided to push the releases back by a few weeks. Anyway WSO2 Carbon 2.0 and four of the Carbon based WSO2 products (WSAS 3.1, ESB 2.1, G-Reg 3.0 and IS 2.0) were released on 8th July 2009 and you can now download them from the download page of the WSO2 Oxygen Tank.

WSO2 Carbon is an OSGi based application framework for SOA and Web Services. All WSO2 Java products including WSO2 ESB, WSO2 WSAS, WSO2 Governance Registry and WSO2 Identity Server are based on this revolutionary SOA platform. We have made some very important architectural and functional enhancements to WSO2 Carbon recently. Therefore the users of Carbon 2.0 based products will be able to reap the benefits of those improvements in the forms of improved performance, reliability, extensibility, user friendliness and stability.

One of the most important architectural changes we made to the Carbon platform this time around is getting rid of OSGi bundle activators and instead, adapting OSGi declarative services to handle bundle initialization and cleanup. OSGi declarative services are considered the best solution when it comes to managing systems with a large number of OSGi bundles. Declarative services allow bundles to startup and initialize properly while sharing required data among various bundles without following a pre configured bundle startup order. Declarative services also helped us improve the dynamic nature of the overall Carbon platform, so now starting bundles and stopping bundles at runtime is easier and safer.

Another key enhancement we did for this release of Carbon is the introduction of the P2 based provisioning system. This work is still at its early stages but it already enables Carbon and Carbon based product users to easily deploy Carbon components, user developed OSGi bundles, mediators and third party dependencies to the system easily, without having to write a single line of code to handle OSGi initialization or cleanup work.

In General Carbon 2.0 and Carbon 2.0 products have better registry integration support, better transport management support, better user management support, better security features and better user interfaces. We gave most of the Carbon component UIs a fresh look through the extended use of AJAX. Persistence of configuration data is another area where we have done a lot of work lately. WSO2 ESB 2.1 in particular has the ability to store the entire ESB configuration in a registry and then load the configuration back from the registry during server startup.

Documentation is yet another area that’s been largely improved with this release. We paid special attention to improving our context sensitive help documents (accessed via product user interfaces) and other downloadable guides and tutorials. In the previous releases of Carbon and Carbon based products we were mostly focused on system architecture and functionality. But now the Carbon framework is largely stabilized we were able to spare some cycles for improving our documentation too. We have added lots of new guides and catalogs including mediator catalog, transports catalog, server administration guide and the endpoints guide. Our plan is to make our products easy to learn and use via making our user interfaces simple, integrating help with the user interfaces and making ample documentation freely available to all.

In addition to the key improvements mentioned above Carbon 2.0 and related products come with tons of new features, minor bug fixes, performance enhancements and usability improvements which add lot of value to the WSO2 Carbon SOA platform. If you are interested in SOA and Web Services middleware you must give some of the new Carbon 2.0 based WSO2 products a try. After all it’s totally free and open source so it doesn’t cost you a penny to try our software. I guarantee that it would be a great experience and after that you will love WSO2 products.

On a finishing note I would like to quote the WSO2 Carbon 2.0 release note here….

WSO2 Carbon 2.0.0 - Middleware a' la carte

Welcome to the WSO2 Carbon 2.0.0 release. This release is available for download at http://wso2.org/projects/carbon

WSO2 Carbon is the base platform for all WSO2 Java products. Built on OSGi, Carbon encapsulates major SOA functionality such as data services, business process management, ESB routing/transformation, rules, security, throttling, caching, logging and monitoring. These product capabilities are no longer tied to individual products, but are available as components.

A Carbon feature consists of one or more Carbon components. These are nothing but Eclipse equinox P2 features. In order to extend the functionality of you Carbon server, simply install new features onto you server as outlined in https://wso2.org/wiki/display/carbon/p2-based-provisioning-support

Key Features
  1. Extensible OSGi component based architecture
  2. P2 provisioning based feature enhancement of the server
  3. Unified server management framework
  4. Unified Management Console
  5. Web service, JMX & Equinox OSGi console based administration
  6. Integrated security & permissions management
New Features In This Release
  • Experimental Equinox P2 based provisioning support - extend your Carbon instance by installing new P2 features (See https://wso2.org/wiki/display/carbon/p2-based-provisioning-support)
  • Fixed start levels eliminated
  • Performance improvements to the Registry
  • Ability to make normal jar files into OSGi bundle (Just copy the jar files into CARBON_HOME/repository/components/lib)
  • Various bug fixes and enhancements including architectural improvements to Apache Axis2, Apache Rampart, Apache Sandesha2 , WSO2 Carbon and other projects, including security fixes
How to Run
  1. Extract the downloaded zip
  2. Go to the bin directory in the extracted folder
  3. Run the wso2server.sh or wso2server.bat as appropriate
  4. Point you browser to the URL https://localhost:9443/carbon/
  5. Use "admin", "admin" as the username and password.
  6. If you need to start the OSGi console with the server use the property -DosgiConsole when starting the server
For more details, run, wso2server.sh (wso2server.bat) --help

How to Install Additional Features

You can build your own server by selecting only the features that you require
For further details refer to
Known Issues

All known issues have been recorded at
Training

WSO2 Inc. offers a variety of professional Training Programs, including training on general web services as well as WSO2 Carbon, Apache Axis2, Data Services and a number of other products.

For additional support information please refer to
Support

WSO2 Inc. offers a variety of development and production support programs, ranging from web-based support up through normal business hours, to premium 24x7 phone support.

For additional support information please refer to
For more information on WSO2 Carbon, visit the WSO2 Oxygen Tank (http://wso2.org)