Monday, June 9, 2014


Hector Exception ?? ... wonder where Achilles was :p

The following exception is related to port offsets.

TID: [0] [BAM] [2014-06-06 14:51:06,015] ERROR {org.wso2.carbon.databridge.datasink.cassandra.subscriber.BAMEventSubscriber} -  Error processing event.  {org.wso2.carbon.databridge.datasink.cassandra.subscriber.BAMEventSubscriber} me.prettyprint.hector.api.exceptions.HectorException: All host pools marked down. Retry burden pushed out to client.
at org.wso2.carbon.databridge.persistence.cassandra.datastore.ClusterFactory.getCluster(
at org.wso2.carbon.databridge.datasink.cassandra.subscriber.BAMEventSubscriber.receive(
at java.util.concurrent.Executors$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: me.prettyprint.hector.api.exceptions.HectorException: All host pools marked down. Retry burden pushed out to client.
at me.prettyprint.cassandra.connection.HConnectionManager.getClientFromLBPolicy(
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(
at me.prettyprint.cassandra.service.AbstractCluster.describeKeyspace(
at org.wso2.carbon.databridge.persistence.cassandra.datastore.CassandraConnector.createKeySpaceIfNotExisting(
at org.wso2.carbon.databridge.persistence.cassandra.datastore.ClusterFactory.initCassandraKeySpaces(
at org.wso2.carbon.databridge.persistence.cassandra.datastore.ClusterFactory$1.load(
at org.wso2.carbon.databridge.persistence.cassandra.datastore.ClusterFactory$1.load(
... 12 more

If you get this in BAM that means you are running BAM with a port offset and have not offset accordingly in the <BAM_HOME>/repository/conf/etc/hector-config.xml file. 

Scheduled Tasks with WSO2 ESB

This article demonstrates how to create a simple scheduled task using the WSO2 ESB.

This is an example that you can complete withing 5 minutes and will give you a basic understanding of how easy it is to deploy a scheduled task using the WSO2 ESB.

1. Create Task class
2. Export task class as a jar
3. Add to WSO2 ESB classpath
4. Create Scheduled task

Step 1:
First of all you need to create a Task Class. For this example we will create a simple class that prints out "HELLO" and a timestamp.

First download the synapse-core-1.2.jar from either the Synapse site or from the Maven Repository

Create a Java Project in eclipse (or any IDE you preffer) and create the following class:

package wso2.demo.taskt;


import java.util.Date;

import org.apache.synapse.ManagedLifecycle;

import org.apache.synapse.core.SynapseEnvironment;
import org.apache.synapse.startup.Task;

public class SayHello implements Task, ManagedLifecycle {

private SynapseEnvironment synapseEnvironment;


public void destroy() {
// TODO Auto-generated method stub



public void init(SynapseEnvironment arg0) {
this.synapseEnvironment = synapseEnvironment;


public void execute() {

try {
File file = new File("E:\\sayhello.txt");
// if file doesnt exists, then create it
if (!file.exists()) {

FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);

BufferedWriter bw = new BufferedWriter(fw);
bw.write("---------------- HELLO ----------------- "+ (new Date()).toString() + "\n");
} catch (IOException e) {


Step 2:
Export the above class as a Jar file. Say with the name SayHello.jar

Step 3:
Add the above class to the ESB Class path by placing it in the <ESB_HOME>/repository/components/lib directory.

Step 4:

Now you can create the Scheduled task in your ESB.

1. Login to the ESB

2. Select "Scheduled Tasks" under the "Main" tab

3. Add a new task

Replace the Task Implementation field with the qualified name of the class you created.

In the next section the Trigger type would be what type of scheduled task you want it to be. By simply defining the count and interval, or by providing a cron expression. Lets select "simple" for this example.

Count - defines how many times your job needs to run
Interval - specifies time gap between task executions

Click Schedule to save the task.

Aaaand That's it ...

Your output file would show the following:

---------------- HELLO ----------------- Mon Jun 09 20:11:37 IST 2014
---------------- HELLO ----------------- Mon Jun 09 20:11:42 IST 2014
---------------- HELLO ----------------- Mon Jun 09 20:12:46 IST 2014
---------------- HELLO ----------------- Mon Jun 09 20:12:51 IST 2014
---------------- HELLO ----------------- Mon Jun 09 20:12:56 IST 2014
---------------- HELLO ----------------- Mon Jun 09 20:13:01 IST 2014

For more options in creating scheduled tasks visit the following page:
Adding and Scheduling tasks in WSO2 ESB