Pages

Monday, March 31, 2014

Exchange types in an AMQP messaging protocol

There are several types of exchanges in AMQP protocol

  • fanout - messages are published to all queues
  • direct - messages are delivered if the message's routing key is identical to the queue's binding key.
  • topic - The exchange routes messages to the relevant queue or queues, depending on matches between the routing and binding keys
  • header - headers of the messages, and the binding key constraints of the queues are used to determine the correct queue/queues
A good article about the above is explained in detail in the following article.

Friday, March 28, 2014

RabbitMQ commands

To check the status of the RabbitMQ issue
sudo rabbitmqctl status

To stop the message broker issue,
sudo rabbitmqctl stop

To restart the message broker issue,
sudo invoke-rc.d rabbitmq-server start

Thursday, March 27, 2014

HazelCast --> what is hazel cast?

Today I looked at HazelCast and wrote some code using the library. I found this library to be extremely useful and simple. Some of the advantages found in hazelcast are,
  1. It can be used as a No-SQL data store - http://www.hazelcast.org/use-cases/in-memory-nosql/
  2. Useful for messaging (pub/sub, topics etc...) - http://www.hazelcast.org/use-cases/messaging/
  3. Can be used as a data-grid - http://www.hazelcast.org/use-cases/data-grid/
  4. Can be used for caching - http://www.hazelcast.org/use-cases/caching/
  5. For application scaling - http://www.hazelcast.org/use-cases/application-scaling/
  6. For clustering sessions in java web apps - http://www.hazelcast.org/use-cases/clustering/

Tuesday, March 18, 2014

How to install mysql on jboss as a module

first create the folder structure <jboss directory>/modules/com/mysql/main
copy the the mysql connector jar to the folder
thlen add module.xml file to the same folder and add the following to the module.xml

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
  <resources>
     <resource-root path="mysql-connector-java-5.1.28.jar"/>            
  </resources>
  <dependencies>
     <module name="javax.api"/>
  </dependencies>
</module>

Note that the resource-root element's path should be the file name of the mysql connector jar

Now the final step

edit the standalone.xml file in standalone/configuration folder. then add the following in the drivers element.
<driver name="mysqlDriver" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>

note the mysqlDriver is the name of the driver and you can use it to configure the data source.

Thursday, March 13, 2014

clustering

clustering an application enables apps to scale out and cater a large audience. most renowned servers supports this feature. when one node goes down other nodes are present to cater the user requests. but what happens to the session of the server which went down? well the session replication across the cluster becomes very important in this case. if you take jboss, it replicates using messages. tomcat also supports it when it is clustered and uses a communication framework called Tribes to achieve it.

A simple how to cluster and do session replication with jboss can be found in the following article.

https://docs.jboss.org/author/display/AS71/AS7+Cluster+Howto?_sscc=t

Usefull maven test commands


some usefull maven commands can be found in the following link

http://kishanthan.wordpress.com/2012/04/30/useful-maven-commands/

What is integrating testing

Integration testing is test to verify that an external service call responds correctly to your input data.

if a test uses

  • the database
  •  an external system (e.g. a queue or a mail server)
  • a test reads/writes files or performs other I/O
  • the network
it is normally an integration test. Arquillian is a popular testing framework that supports integration testing.

How to do maven unit tests

to test the app simply issue the following command

mvn test

to run a single test issue

mvn -Dtest=<test class name> test

to skip unit testing while building  issue put the following directive to your maven goal

-Dmaven.test.skip=true


Tuesday, March 4, 2014

jersy vs apache cxf

Well jersy is a simple framework for REST full web services. Usage of it is pretty straight forward. Apache cxf is better if you need to work with SOAP web services. It all depends on what protocol you like to use. if REST then jersy works well while for SOAP apache cxf does the job.

Another thing to notice is that SOAP uses WSDL and the equivanlent of it in REST world is WADL. But still WADL is not standardized.

http://en.wikipedia.org/wiki/Web_Application_Description_Language.

For more info read the following article.

http://stackoverflow.com/questions/2704700/java-rest-implementation-jersey-vs-cxf

A simple resutfull implementation with jersy is described in the below article.

http://www.vogella.com/tutorials/REST/article.html