Wednesday, May 27, 2015

JBoss FSW Connect ActiveMQ Using ActiveMQ Resource Adapter


In order to use external ActiveMQ as message broker, we have install and configure ActiveMQ resource adapter. The resource adapters are the plug-ins for JEE containers. They facilitate the communicates between JEE container and external brokers, databases, etc.

In this post, I am going to demonstrate in details about how to setup and test the ActiveMQ resource adapter. I use my local environment to setup SSL connection to my local ActiveMQ instance.

Install ActiveMQ Resource Adaptoer activemq-rar.rar

Download activemq-rar

activemq-rar (version 5.11.1) file is available at If you need older version, you can brower the maven repo, and download it accordingly.

Install activemq-rar

  • copy activemq-rar-5.11.1.rar to $JBOSS_FSW_HOME/standalone/deployments
  • mv activemq-rar-5.11.1.rar activemq-rar.rar

Modify JBoss FSW Configuration Files

Here is configuration change on standalone.xml. If you use standalone-full.xml or standalone-fule-ha.xml, do the same.


Another section needs to change is the following:


Import ActiveMQ Public Keystore

If you use tcp, there is no need to import certs. However in the enterprise application, nio+ssl is preferred. Thus, we need to perform the following step:

   sudo keytool -import -alias Guojiangs-MacBook-Pro.local \
      -file Guojiangs-MacBook-Pro.local_cert \
      -keystore /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/security/cacerts 

Where Guojiangs-MacBook-Pro.local_cert is public key for the activemq. For how to setup SSL for ActiveMQ, you can refer my blogs:

Test The Configuration

First start JBoss FSW without start ActiveMQ. In such a way, we can see the features of automatic reconnection from JBoss FSW.

12:22:23,724 ERROR [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 2) Failed to connect to broker [ssl://localhost:61617?jms.rmIdFromConnectionId=true]: Could not connect to broker URL: ssl://localhost:61617. Reason: Connection refused: javax.jms.JMSException: Could not connect to broker URL: ssl://localhost:61617. Reason: Connection refused
	at org.apache.activemq.util.JMSExceptionSupport.create( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.ActiveMQConnectionFactory.createConnection( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.ra.ActiveMQResourceAdapter.makeConnection( [activemq-ra-5.11.1.jar:5.11.1]
	at org.apache.activemq.ra.ActiveMQEndpointWorker$ [activemq-ra-5.11.1.jar:5.11.1]
	at [ironjacamar-core-impl-1.0.19.Final-redhat-2.jar:1.0.19.Final-redhat-2]
	at org.jboss.threads.SimpleDirectExecutor.execute(
	at org.jboss.threads.QueueExecutor.runTask(
	at org.jboss.threads.QueueExecutor.access$100(
	at org.jboss.threads.QueueExecutor$
	at [rt.jar:1.7.0_75]
Caused by: Connection refused
	at Method) [rt.jar:1.7.0_75]
	at [rt.jar:1.7.0_75]
	at [rt.jar:1.7.0_75]
	at [rt.jar:1.7.0_75]
	at [rt.jar:1.7.0_75]
	at [rt.jar:1.7.0_75]
	at [jsse.jar:1.7.0_75]
	at org.apache.activemq.transport.tcp.TcpTransport.connect( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.tcp.TcpTransport.doStart( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.util.ServiceSupport.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.AbstractInactivityMonitor.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.TransportFilter.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.WireFormatNegotiator.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.TransportFilter.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.transport.TransportFilter.start( [activemq-client-5.11.1.jar:5.11.1]
	at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection( [activemq-client-5.11.1.jar:5.11.1]
	... 10 more

12:22:23,726 ERROR [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 1) Endpoint will try to reconnect to the JMS broker in 30 seconds
12:22:23,727 ERROR [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 2) Endpoint will try to reconnect to the JMS broker in 30 seconds

Now start the activemq broker. After about 30 seconds, you should see something like this:

12:23:23,806 INFO  [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 1) Successfully established connection to broker [ssl://localhost:61617?jms.rmIdFromConnectionId=true]
12:23:23,813 INFO  [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 2) Successfully established connection to broker [ssl://localhost:61617?jms.rmIdFromConnectionId=true]

This means the connection between JBoss FSW and ActiveMQ is established. To prove this, we can issue the following commands:

Gary2013@Guojiangs-MacBook-Pro:~/jFSW/6.1/jboss-eap-6.1/standalone$ lsof -iTCP -P | egrep 61617 | egrep ESTAB
java      10669 Gary2013 1063u  IPv4 0x9b93e9761ab85c83      0t0  TCP localhost:55666->localhost:61617 (ESTABLISHED)
java      10669 Gary2013 1064u  IPv4 0x9b93e976184e1fc3      0t0  TCP localhost:55667->localhost:61617 (ESTABLISHED)
java      10777 Gary2013  149u  IPv6 0x9b93e976130931b3      0t0  TCP localhost:61617->localhost:55666 (ESTABLISHED)
java      10777 Gary2013  159u  IPv6 0x9b93e97613092cb3      0t0  TCP localhost:61617->localhost:55667 (ESTABLISHED)

Now, we can check the JNDI name from the JBoss FSW console. Here is what I see:


Redhat References

Tuesday, May 19, 2015

JBoss FSW Switchyard Tutorial 3: SOAP Binding


This is my third tutorial on Switchyard Binding. So far, I have covered, SCA, REST, and SOAP bindings. The use cases for this is to retrieve Person information using SOAP web service

The source code is available at github:

The live demo is available at youtube:

Wednesday, May 13, 2015

JBoss FSW Switchyard Tutorial 2: REST Binding


The source code for this tutorial is available at:

The video demo for this blog is available at youtube here now.

In my previous tutorial, I have covered the basics about Switchyard design, using the example of creating a Hello World Service. The link is available here:

The main purpose of this article is to document the basic procedures of the creation of a REST binding for Switchyard application. The 1.1 implementation still has some bugs. There are still quite some room for improvement in terms of simplicity and intuitiveness.

Create Order Service

Step One: Create Project

New --> Switchyard Project.
Project name: switchyard-rest, Next
Fill the form like the following:
click Finish

A new Switchyard project will be created. However, there is problem with pom.xml. This is a know bug for the version 1.1.1-p5-redhard-1. The workaround is to add a parent segment. Here is the complete pom.xml content:


This is pretty nasty work around. Your project version has to be the same as the switchyard version. As I know this is fixed in the newer version of switchyard. I will verify that soon.

We need to update the maven project as the pom.xml file is modified [using Option-F5 in MacOS].

Create OrderService

This is the same as my previous HelloWorld service, exception the interface name is OrderService and the bean name is OrderServiceImpl.

Create REST Binding

Switchyard for REST service require a resource file, which is an interface definition. In my case, I have defined as the following:

package com.ggl.switchyard.switchyard_rest_demo;


public interface OrderResource {

    public Order newOrder();

    public Order getOrder(@PathParam("orderId") Long orderId);


This interface must be the same as the implementation service interface. In this tutorial, I have defined the OrderService as the following:

public interface OrderService {
 public Order newOrder (Order order);
 public Order getOrder (Long orderId);

As you can see that the signature is the same if you remove the annotations from the resource interface. This seems a bit awkward. To me there should be an implementation for the REST service explicitly, like in Spring MVC, of Apache CXF


Thursday, May 7, 2015

JBoss FSW Switchyard Tutorial 1: HelloWorld


The video version is available at:
The video for the blog is availabe at youtube now.

In my earlier blog, I have documented how to setup JBoss FSW development environment using JBoss Developer studio 7.1. The blog can be refered at

The purpose of this blog is to demonstrate the development process of switchyard application using JBoss Developer Studio 8.1. I will create a Hello World application from scratch, deploy it, and test it. Thus, people can learn the stuff in a ground-up style.

Now, JBDS 8.1 is available. The setup procedure is the same. Make update the Integration Stack from the Software/Update panel in the JBoss Central page as shown below

Procedures To Build The Project

Create Project

Create New Switchyard Project:
Give the project name and Click Next:
Configure the SwitchYard component:
Click Finish. You will see the following:
Drag the Bean Implementation from the Pallet to the Canvas. Fill the HelloWorldBean and HellowWorldService, click finish on both:
Modify the like the following:
package switchyard_helloworld_demo;

public interface HelloWorldService {
 public String sayHello( String name);

Modify the as the following:
package switchyard_helloworld_demo;

import org.switchyard.component.bean.Service;

public class HelloWorldServiceBean implements HelloWorldService {

 public String sayHello(String name) {
  return "Hello " + name + "!";

Now the JBDS looks like this:
Promote The Service:
Click Finish in the new Promote service panel and you will see this:
Bind to SCA:
At this time, we are done with the HelloWorldService.

Test The HelloWorld Service

Now we need to create a test class as the following:
package com.ggl.switchyard_helloworld_demo;

import static java.lang.System.out;
import javax.xml.namespace.QName;

import org.switchyard.remote.RemoteInvoker;
import org.switchyard.remote.RemoteMessage;
import org.switchyard.remote.http.HttpInvoker;

 * Test client which uses RemoteInvoker to invoke a service with an SCA binding.
public final class RemoteClient {

    private static final QName SERVICE = new QName(
    private static final String URL = "http://localhost:8080/switchyard-remote";

     * Private no-args constructor.
    private RemoteClient() {

     * Only execution point for this application.
     * @param ignored not used.
     * @throws Exception if something goes wrong.
    public static void main(final String[] ignored) throws Exception {
        // Create a new remote client invoker
        RemoteInvoker invoker = new HttpInvoker(URL);

        RemoteMessage message = new RemoteMessage();
        message.setService(SERVICE).setOperation("sayHello").setContent("My Dear Earth");

        // Invoke the service
        RemoteMessage reply = invoker.invoke(message);
        if (reply.isFault()) {
            System.err.println("Oops ... something bad happened.  "
                    + reply.getContent());
        } else {
            String greeting = (String) reply.getContent();
            out.println("Got reply from HelloWorld Service: " + greeting);


Deploy the service and start the runtime. You can right click the the and run as java application. You should see the following:
log4j:WARN Continuable parsing error 2 and column 69
log4j:WARN Document root element "log4j:configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 69
log4j:WARN Document is invalid: no grammar found.
Got reply from HelloWorld Service: Hello My Dear Earth!

Monday, May 4, 2015

JBoss Switchyard Application pom.xml Fix

The Issue

When you import switchyard application from JBoss quickstart project, you may see the Jboss Devveloper Studio [JBDS] complain about the execution task. This is a well know problem.

The Solution

To fix this problem, simple put the following code to the pom.xml before the end of build tag like the following:

Make sure update the maven project

Friday, May 1, 2015

Solution For The Failure Of Mule Project Build With Maven

The Issue

If you build a Mule project in the Anypoint Studio, you can run the project with the Studio, and everything works fine. However, if you try to build using mvn clean install from shell console, the compilation will fail. Here is the message:

[ERROR] Failed to execute goal on project http-jms: Could not resolve dependencies for project com.ggl.mule.jms:http-jms:mule:1.0.0-SNAPSHOT: The following artifacts could not be resolved:, com.googlecode.sardine:sardine:jar:248: Failure to find in was cached in the local repository, resolution will not be reattempted until the update interval of redhat-techpreview-all-repository has elapsed or updates are forced -> [Help 1]

The Solution

You may attempt to modify the pom.xml and add the following dependence:

This is not the sulution, because if later on, Mule change the version of the dependency, you will have to update for this again. The solution I found is to add the following repository to the pom.xml file:


Email Address Validation Using Dataweave Regex

Introduction This short article is about how to use regex with Dataweave 2.0 with regard to email validation. Regex is used in Mulesoft lan...