Monday, October 17, 2011

Transport error occurred during acceptance of message. org.apache.thrift.transport.TTransportException: java.net.SocketException: Too many open files


WARN 13:59:01,693 Transport error occurred during acceptance of message.
org.apache.thrift.transport.TTransportException: java.net.SocketException: Too many open files\



This is a common error occurs when using cassandra. This is caused due to the file limit of the system. To overcome this problem , we need to increase the file limit of the system.

you can follow this post to increase the file limit and it will solve this problem.

Tuesday, October 11, 2011

Sample Java client for RabbitMQ

Here you can find sample java client for RabbitMQ. I have taken this from Programming fun at startup blog. I have tried this and working
fine with out any issue.


Steps to follow :

1. Install RabbitMQ server : http://www.rabbitmq.com/install.html#debian

2. Download RabbitMQ client libraries : http://www.rabbitmq.com/java-client.html

3. Start the installed RabbitMQ Server

4. Use the downloaded client libraries for the following consumer and the sender.

5. Start the consumer first and then the Producer


-------------------RabbitMQProducer.java-----------------------------


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.*;

public class RabbitMQProducer {
public static void main(String []args) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setVirtualHost("/");
factory.setHost("127.0.0.1");
factory.setPort(5672);
Connection conn = factory.newConnection();
Channel channel = conn.createChannel();
String exchangeName = "myExchange";
String routingKey = "testRoute";
byte[] messageBodyBytes = "Hello, world!".getBytes();
channel.basicPublish(exchangeName, routingKey
,MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes) ;
channel.close();
conn.close();
}
}

----------------------RabbitMQConsumer.java----------------------------------


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.*;
public class RabbitMQConsumer {
public static void main(String []args) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setVirtualHost("/");
factory.setHost("127.0.0.1");
factory.setPort(5672);
Connection conn = factory.newConnection();
Channel channel = conn.createChannel();
String exchangeName = "myExchange";
String queueName = "myQueue";
String routingKey = "testRoute";
boolean durable = true;
channel.exchangeDeclare(exchangeName, "direct", durable);
channel.queueDeclare(queueName, durable,false,false,null);
channel.queueBind(queueName, exchangeName, routingKey);
boolean noAck = false;
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, noAck, consumer);
boolean runInfinite = true;
while (runInfinite) {
QueueingConsumer.Delivery delivery;
try {
delivery = consumer.nextDelivery();
} catch (InterruptedException ie) {
continue;
}
System.out.println("Message received"
+ new String(delivery.getBody()));
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
channel.close();
conn.close();
}
}


Another nice article on this can be found here.

Tuesday, September 27, 2011

How to wrap the maven script with ant ?

Most of the time people need to do the other way around.
That mean to wrap ant scripts with maven scripts. But ,
in some rare situations there are people who want to wrap
maven scripts with ant scripts.

It is very easy to do this. You need to have maven
installed and set the MVN_HOME for this.


<project default="buildProject">
  <property name="source.dir" value="."/>
<target name="buildProject" description="Wrapper for the maven script">
<exec dir="${source.dir}" executable="mvn">
<arg line="clean install" />
</exec>
</target>
</project>


place this code segment in your build.xml file. Place
that build.xml file in the folder which you have the
maven script (pom.xml). Go to the folder with command
prompt. Execute "ant" command. Thats all...!

Thursday, September 22, 2011

error=24, Too many open files

Many users have experience in getting this error when building with maven.

The way to over come this problem is to increase the file limit of the OS.

First, in order to set this options automatically you have to edit the etc/security/limits.conf file.

$sudo gedit /etc/security/limits.conf

with the above command you can open the "limits.conf" file with gedit.
We need to set the nofile option meaning maximum number of open files.If you want to change the number of files of user, you should add this line in the limits.conf file.

Lets say our user name is "foo"

Then the entry should be

foo soft nofile 9000

foo hard nofile 65000




If you want to set the nofile only for superuser you just write root instead of user.


root soft nofile 9000

root hard nofile 65000



Now after rebooting you can see in the terminal with ulimit -a the change.

Wednesday, September 21, 2011

How to disable the web administration console? http://localhost:8080/axis2/axis2-admin/

How to disable the web administration console? http://localhost:8080/axis2/axis2-admin/

Environment:
Axis2-1.6.0

This is a common problem that many users asks and most of them thinks
that this can be done by changing a property in axis2.xml file.

There are more than one way to carry out this task. First we need to
say that axis2.xml has no control on disabling this admin console.
Because of that, changing the properties of axis2.xml file will not
effect on this requirement.

Here i ll specify two different ways to fulfill your requirement.
Both of them will prevent accessing the JSP file which is required to
load the Web Admin Console.

01: Changing the web.xml file

You can find this file at : webapps/axis2/WEB-INF folder.
In this file , you will find the following entry

<servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping>

You can comment this entry like

<!--servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping-->


This will prevent the page redirection and it will solve your problem.

02: Renaming or Deleting the Login.jsp file

You can find this file at : webapps/axis2/axis2-web folder.
you can delete or rename this file to any other name.
This will prevent access to Login page and it will solve your problem.

Friday, August 5, 2011

Hector Client Exception : InvalidRequestException(why:Expected 8 or 0 byte long (9))

We are getting the following kind of exception due to a small mistake that we do in creating column families in cassandra. I had created the column family with providing
comparator type as LONG.

But once i try to insert columns having String values as column names it throws this error.

Solution: Drop the created column family using cassandra-cli
create the Column Family with appropriate comparator type


me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:95)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:88)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:156)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:100)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:106)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:172)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:169)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:72)
at me.prettyprint.cassandra.model.MutatorImpl.execute(MutatorImpl.java:169)
at org.apache.qpid.server.store.CassandraMessageStore.addMessageContent(CassandraMessageStore.java:267)
at org.apache.qpid.server.store.CassandraMessageStore$StoredCassandraMessage.addContent(CassandraMessageStore.java:620)
at org.apache.qpid.server.queue.IncomingMessage.addContentBodyFrame(IncomingMessage.java:144)
at org.apache.qpid.server.AMQChannel.publishContentBody(AMQChannel.java:391)
at org.apache.qpid.server.protocol.AMQProtocolEngine.contentBodyReceived(AMQProtocolEngine.java:477)
at org.apache.qpid.framing.ContentBody.handle(ContentBody.java:83)
at org.apache.qpid.server.protocol.AMQProtocolEngine.frameReceived(AMQProtocolEngine.java:336)
at org.apache.qpid.server.protocol.AMQProtocolEngine.dataBlockReceived(AMQProtocolEngine.java:285)
at org.apache.qpid.server.protocol.AMQProtocolEngine$1.run(AMQProtocolEngine.java:256)
at org.apache.qpid.pool.Job.processAll(Job.java:110)
at org.apache.qpid.pool.Job.run(Job.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:916)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:890)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:93)
... 25 more

me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))

We are getting the following kind of exception due to a small mistake that we do in creating column families in cassandra.

me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:95)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:88)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:156)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:100)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:106)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:172)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:169)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:72)
at me.prettyprint.cassandra.model.MutatorImpl.execute(MutatorImpl.java:169)
at org.apache.qpid.server.store.CassandraMessageStore.addMessageContent(CassandraMessageStore.java:267)
at org.apache.qpid.server.store.CassandraMessageStore$StoredCassandraMessage.addContent(CassandraMessageStore.java:620)
at org.apache.qpid.server.queue.IncomingMessage.addContentBodyFrame(IncomingMessage.java:144)
at org.apache.qpid.server.AMQChannel.publishContentBody(AMQChannel.java:391)
at org.apache.qpid.server.protocol.AMQProtocolEngine.contentBodyReceived(AMQProtocolEngine.java:477)
at org.apache.qpid.framing.ContentBody.handle(ContentBody.java:83)
at org.apache.qpid.server.protocol.AMQProtocolEngine.frameReceived(AMQProtocolEngine.java:336)
at org.apache.qpid.server.protocol.AMQProtocolEngine.dataBlockReceived(AMQProtocolEngine.java:285)
at org.apache.qpid.server.protocol.AMQProtocolEngine$1.run(AMQProtocolEngine.java:256)
at org.apache.qpid.pool.Job.processAll(Job.java:110)
at org.apache.qpid.pool.Job.run(Job.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:916)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:890)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:93)
... 25 more

Monday, July 18, 2011

How to send filtered events from WSO2 Complex Event Processing Server to your mail box

Most important thing in complex event processing is the EVENT. It will be very useful if we can direct the filtered events to the email box of the user which the most frequently accessible thing in busy schedules even with their mobile phones.

If we take a simple example:

There is a person with very busy schedule , who used to place trades in Stock market with his mobile phone. But he has to keep his eye open on the stock prices in order to place a profitable order. With this WSO2 Complex Event Processing Server , we can make his life easy. What he has to do is, Configure the WSO2 Complex Event Processing Server to receive events stream from stock market and filter the events which will be worth to trade and send an e mail to the inbox of the user. Once the email is received to the inbox, user would get the alert and he will be able to place an order via his mobile phone.

With WSO2 Complex event processing server, it will be very easy for the user to direct filtered events to his/her mail box. There are only two steps.

Step 01 : Add mail transport sender to the axis2_client.xml file.

In order to do this place the following code segment in axis2_client.xml file in the "Transport Outs " section.

<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter>
<parameter name="mail.smtp.user">synapse.demo.0</parameter>
<parameter name="mail.smtp.password">mailpassword</parameter>
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
</transportSender>

Save the file and start the server.

Step 02:

Create the bucket in WSO2 Complex Event Processing server. You can find more information on
that here.

Create the output topic through the "Topics" menu of WSO2 Complex Event Processing Server and create a subscription by providing event sink URL as : "mailto:test@test.com". User can provide his email address here. Once this is done, user will get an email on any filtered event from his
CEP bucket.

Tuesday, June 21, 2011

Flash vedios ubuntu not available in /tmp - new location - Browser cache

Users have used to get the hard copies of online vedios from various flash using sites from /tmp directory. But with the latest versions of ubuntu it no longer works.

Users can still find .flv files of viewed videos on their hard-drive but now located in the cache folder for the respective browser used to view them. These are most commonly located in your home folder, for example:

.mozilla/firefox/userprofile/Cache

Monday, February 7, 2011

WSO2 Complex Event Processing Server 1.0.0- Alpha Released...

WSO2 Complex Event Processing Server Development team has released the Alpha version of WSO2 Complex Event Processing Server early January 2011.

What is WSO2 Complex Event Processing Server ?

WSO2 Complex Event Processing server acts same as other CEP Servers on processing events and generating new events on analyzing incoming events from multiple sources.




As you can see in the above diagram , Any Complex Event Processing Server can receive any number of events from any number of event sources. What the CEP Server does is analyzing the content of the receiving event and identify the meaningful events from the receiving event cloud. When multiple events matches with a query specified by a user of the server, it creates a new event indicating the satisfied conditions.


How WSO2 CEP Server is different from others ?


WSO2 Complex Event Processing server introduce Complex Event Processing to SOA World. We have complex event processing servers in standalone mode. Here WSO2 is providing the users to use Complex Event Processing Engines as Web Services. So any user is not needed to have there own server running on their premises to use Complex Event Processing feature on the events received. What he need to do is access a web service providing Complex Event Processing Service by WSO2 Complex Event Processing Server.

What is the Event Processing Engine Running in WSO2 CEP ?


WSO2 Complex Event Processing Server is Running of Drools Fusion Complex Event Processing Engine and it is embedded to the server. Apart from that it is very easy for the user to add the Esper complex Event Processing Engine to WSO2 CEP Server. It is a matter of installing the Esper Feature on WSO2 CEP Server.

What is the basic concept used in WSO2 CEP Server?


In WSO2 CEP Server is developed by WSO2 CEP Development team with the Concept of 'Bucket' to be used in the entire server. Actually a Bucket is an instance of a Complex Event Processing Server.
So when a particular user creates a bucket means, he creates a separate instance of a CEP Engine for him.


Here is the Concept in WSO2 CEP Server..




Can I play with this release?

Yes of course, What you need to do is download the binary distribution of the WSO2 CEP Server and start the server.You can find the binary distribution and the documentation in the following location :

WSO2 Complex Event Processing Server 1.0.0-Alpha

You can find the installation guide for the WSO2 CEP Server in the following location :

WSO2 CEP Installation Guide

What do i have to know to deal with this?

You are not needed to have a huge knowledge on Complex Event Processing to deal with this WSO2 CEP Server. All the basic things used in this server has clearly explained in the User Guide of the documentation of this server.

WSO2 CEP Documentation

It will be an added advantage if you have knowledge on Complex Event Processing and Writing queries with ESPER , and DROOLS Fusion Complex Event Processing Engines.

You can get a broad idea on WSO2 via http://wso2.org/