Reducing the Time Between SCTP Message Received and SCTP_SACK Sent

Last few weeks I was involved with a development related to SCTP protocol in Java. I have also done two posts on how to get started with SCTP. During that project I came across a strange issue. That is I receive two responses for all the packets I send to the peer. After doing some investigation we found that it is due to that from my application SCTP SACK message is sent after 200ms. Because of that delay peer thinks that I have not received the message and sent it again.
That 200ms is a configuration based on the SCTP RFC. According to that an acknowledgment(SACK) should be generated for at least every second packet received, and SHOULD be generated within 200 ms of the arrival of any unacknowledged DATA chunk.So to fix this issue I had to find a way to reduce the delay between message receiving and SACK sending.
We can reduce that time delay by editing the value of /proc/sys/net/sctp/sack_timeout property file. Just use following to set timeout to 50ms. 
echo 50 > /proc/sys/net/sctp/sack_timeout
After doing that that two response issue was fixed.  Thanks Chris at sctp-dev@openjdk.java.net for helping me on fixing this issue.


 

Catching JVM Shutdown event

Shutdown hook is a mechanism provided by java for us to handle shutdown event of our applications. We can attach any piece of code to this and execute them just before JVM exits.

public class ShutDownHookTest {
public static void main(String [] args) throws Exception {
System.out.println("System Started...");

Runtime.getRuntime().addShutdownHook(new Thread( new Runnable() {
public void run() {
System.out.println("System is Shutting Down...");
}
}));

Thread.sleep(10000);
}
}


Compile and run this sample code and press Crt+C to exit the application, you can see that "System is Shutting Down" message prints before application exiting.

But we have to be careful when using this, because if the shutdown code we attach to the shutdown hook end up in an infinite loop, our application will be stuck and only way to exit will be killing the process.
 

InfoQ allow you to download Mp3s

Finally, a feature I was waiting for long time has been included to InfoQ. Now they give the mp3 files of the presentations posted in the site. Previously we had to use some tools to capture the streaming flash video and convert them in to mp3.

 

Command Line Client for JMX

JMX is a mechanism where we can used to monitor and control our java applications remotely. We can expose variables and methods to outside using JMX.  To access these exposed variables or methods, we have to use JMX Client. JConsole is the JMX client application shipped with Java. It is a swing based application.

There is nothing wrong with JConsole if I'm using it in from my desktop. But issue is when I want to run it on a remote machine through ssh, I can't use X because of bandwidth limitations. So ideal tool for such situation is to use CLI tool.

After searching few minutes in goolgle I found this cute little tool called "Jmxterm (JMX  Terminal)". It is again a Java application and give you all the features you need when you use JMX. It is really user friendly as well. It has auto command completion and also can remember previous command you used. It is just like bash.

[sandarenu@localhost jmx-commandline]$ java -jar jmxterm-1.0-alpha-4-uber.jar
Welcome to JMX terminal. Type "help" for available commands.
$>help
#following commands are available to use:
about    - Display about page
bean     - Display or set current selected MBean.
beans    - List available beans under a domain or all domains
bye      - Terminate console and exit
close    - Close current JMX connection
domain   - Display or set current selected domain.
domains  - List all available domain names
exit     - Terminate console and exit
get      - Get value of MBean attribute(s)
help     - Display available commands or usage of a command
info     - Display detail information about an MBean
jvms     - List all running local JVM processes
open     - Open JMX session or display current connection
option   - Set options for command session
quit     - Terminate console and exit
run      - Invoke an MBean operation
set      - Set value of an MBean attribute

$>jvms
2686     ( ) -
12216    ( ) - jmxterm-1.0-alpha-4-uber.jar
12200    ( ) - hsendidmobile.ss7.sampleapp.performance.ApplicationStarter
$>open 12200
$>bean Performance:name=smsSender,type=map
#bean is set to Performance:name=smsSender,type=map
$>info
#mbean = Performance:name=smsSender,type=map
#class name = hsendidmobile.ss7.sampleapp.performance.sms.ForwardMoSenderMBean
#there is no attribute
# operations
  %0   - int currrentTps()
  %1   - void sendMessage()
  %2   - void sendTps(int p1)
  %3   - void sendTpsParallay(int p1,int p2)
  %4   - void stopSending()
#there's no notifications
$>run sendMessage
#calling operation sendMessage of mbean Performance:name=smsSender,type=map
#operation returns:
null

Technorati Tags: ,,
 

Download Presentation Videos from InfoQ

InfoQ is a very resource full web site for anyone in the software industry. They have lot of articles, white papers, and presentations in various topics related to software engineering. Presentation videos found in InfoQ have being recorded during various conferences and are really useful. I really love watching those videos since it is great opportunity to listen to industry experts.

But the problem was that I had to sit in front of the browser and watch those videos. So I though of downloading those videos watch them when I have free time, or when I'm traveling. So I tried to download the flv using many of the free tools available in the web. But they were not successful at all. After many unsuccessful attempts, I found a way to download those presentations. It is a tool called Grub-Pro coming with Orbit-Downloader. Here is the tutorial for it. Only issue with this tool is that you have to use Internet Explorer. But no worries, as long as I can download the video, I don't mind even using IE for a while :)

grub-pro-in-IE

grub-pro-download

 

Task Focused Programing with Mylyn and TaskTop

Few days back I came across this presentation at InfoQ site regarding "Eclipse, Mylyn and the TFI". I've seen the Mylyn view in the Eclipse and my idea about that was like some kind of a task management tool that comes with Eclipse IDE. After watching the vide my idea about Mylyn changed a lot and I was really exited about Mylyn and wanted to give it a try.  Mylyn is an open source product, there is a commercial version as well, which is called TaskTop. In task top there is a free version called "TaskTop Starter" which has some more features like Time Tracking.

Installing Mylyn and TaskTop

Mylyn comes by default with many of Eclipse editions. I was using Eclipse JEE Developer edition and it already had Mylyn. So most probably you also having it already. If you don't have Mylyn pug-in already installed in your Eclipse you can get it from Eclipse site. It has all the instruction you need to install it.

Once you install Mylyn you'll get a new view called "Task". If it is not already shown you can get it from Window -> Show View -> Other.

task-view

To install TaskTop starter edition follow the instructions given in TaskTop site. Before installing TaskTop you should do a complete update of your Eclipse. Otherwise you'll get some errors regarding incompatibilities.

Some Interesting Features of Mylyn/TaskTop

Mylyn is all about task focused programing. It allows you to do multitasking with ease. When you create a task all the editors you open are attached to that task. So when you move to another task you can see all the file which you had opened already there. You don't need to waist time on opening and closing editors when switching from one task to another.  Trust me this can improve your productivity many times. I personally experiences this during last tow days

I used mylyn.

task-list

creating-new-task 

You can also integrate bug reports from common bug tracking systems like bugzilla and Jira. Most interesting thing about this is that you can share how you fix the bug with other developers as well. Lett's say you had to open 5 files and do changes in order to fix the bug. When you mark the bug as Fixed you can also attach Mylyn context as well. So when other open it, mylyn will automatically open the files you have opened when you fixed that bug.

Another interesting thing is you can see how you have spent your time on various tasks you have performed during the day. This feature comes with the TaskTop Starter.

time-tracking

There are many more interesting things regarding Mylyn. This is only an enlightment article. If you are interested you should watch that InfoQ video.

 

 

SCTP Client-Server in Java

As I promised in my previous article here is very simple Client Server example for SCTP in Java. If you still have not installed and tested OpenJDK please follow the instructions given in my previous article.

SCTP Server

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;

import com.sun.nio.sctp.MessageInfo;
import com.sun.nio.sctp.SctpChannel;
import com.sun.nio.sctp.SctpServerChannel;

/**
* @author sandarenu
* $LastChangedDate$
* $LastChangedBy$
* $LastChangedRevision$
*/
public class SctpServer {

    public static void main(String[] args) throws IOException {
        SocketAddress serverSocketAddress = new InetSocketAddress(1111);
        System.out.println("create and bind for sctp address");
        SctpServerChannel sctpServerChannel =  SctpServerChannel.open().bind(serverSocketAddress);
        System.out.println("address bind process finished successfully");

        SctpChannel sctpChannel;
        while ((sctpChannel = sctpServerChannel.accept()) != null) {
            System.out.println("client connection received");
            System.out.println("sctpChannel.getRemoteAddresses() = " + sctpChannel.getRemoteAddresses());
            System.out.println("sctpChannel.association() = " + sctpChannel.association());
            MessageInfo messageInfo = sctpChannel.receive(ByteBuffer.allocate(64000) , null, null);
            System.out.println(messageInfo);

        }
    }
}

SCTP Client

 

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;

import com.sun.nio.sctp.MessageInfo;
import com.sun.nio.sctp.SctpChannel;

/**
* @author sandarenu
* $LastChangedDate$
* $LastChangedBy$
* $LastChangedRevision$
*/
public class SctpClient {

    public static void main(String[] args) throws IOException {
        try {
            SocketAddress socketAddress = new InetSocketAddress( 6050);
            System.out.println("open connection for socket [" + socketAddress + "]");
            SctpChannel sctpChannel = SctpChannel.open();//(socketAddress, 1 ,1 );
            sctpChannel.bind(new InetSocketAddress( 6060));
            sctpChannel.connect(socketAddress, 1 ,1);

            System.out.println("sctpChannel.getRemoteAddresses() = " + sctpChannel.getRemoteAddresses());
            System.out.println("sctpChannel.getAllLocalAddresses() = " + sctpChannel.getAllLocalAddresses());
            System.out.println("sctpChannel.isConnectionPending() = " + sctpChannel.isConnectionPending());
            System.out.println("sctpChannel.isOpen() = " + sctpChannel.isOpen());
            System.out.println("sctpChannel.isRegistered() = " + sctpChannel.isRegistered());
            System.out.println("sctpChannel.provider() = " + sctpChannel.provider());
            System.out.println("sctpChannel.association() = " + sctpChannel.association());

            System.out.println("send bytes");
            final ByteBuffer byteBuffer = ByteBuffer.allocate(64000);
            //Simple M3ua ASP_Up message
            byte [] message = new byte []{1,0,3,1,0,0,0,24,0,17,0,8,0,0,0,1,0,4,0,8,84,101,115,116};

            final MessageInfo messageInfo = MessageInfo.createOutGoing(null, 0);
            System.out.println("messageInfo = " + messageInfo);
            System.out.println("messageInfo.streamNumber() = " + messageInfo.streamNumber());

            byteBuffer.put(message);
            byteBuffer.flip();

            try {
                sctpChannel.send(byteBuffer, messageInfo);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("close connection");
            sctpChannel.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Technorati Tags: ,,,

 

Communicating over SCTP in Java

SCTP - Stream Control Transmission Protocol is a relatively new (standardize in year 200 by IETF) transport layer protocol to design to operate over IP. It is an alternative for TCP and UDP and combines many good features of those protocols. Main intention of developing SCTP was to cater the growing demand of IP telephony market. 

Since SCTP is relatively new protocol programming language support for this is also not as commonly available as TCP or UDP, especially you are Java developer. But is you are a C/C++ developer then you have no problem, there is a very good guide on UNIX - Network Programing Vol1-3rd Edition (chapter 9, 10 and 23).

If you are Java developer then you'd have to use OpenJDK instead of Sun java JDK, since at present only OpenJDK has the support for SCTP. So first thing you have do is to download and install OpenJDK-7.  Currently it only has versions for Linux and Solaris, again if you are using Windows then you'll have to do some more research. I've tried this only on Linux(Fedora), may be later I'll try with Windows as well. If your Linux kernel do not support SCTP, then you'll have install LKSCTP as well. Here is the small getting started guide at OpenJDK site. You can use the small test program given that guide to test whether your SCTP stack if working properly. I'll post small client-server program in SCTP in a later post.

PS: I found this SCTP library for Windows http://www.sctp.be/sctplib/, but couldn't check whether there is a support from OpenJDK-SCTP side for windows. If you find something please let me know as well.

Technorati Tags: ,,,,
 

OpenCV - Haar Training Resources

There were lot of good feed back for my OpenCV articles (Article1, Article 2). There were lot of inquires regarding Haar Training and how to do it. Since I was bit busy with my work at hSenind I couldn't put any replies for that. Finally I managed to find some time to put together few URL and important tools where you can use to create your own classifier XML.

If you are interested in OpenCV vision library you should join to OpenCV yahoo group. It is very active and has lot of resources as well.  Following are some good links I used when I was learning on how to do Haar Training with OpenCV.

Most important thing to consider when doing Haar training is to have good positive and negative image set. We have created a small utility modifying sample program provide with OpenCV to create positive samples. You can download the source here. Using that you can create positive samples to detect some object using a video. You can move frame by frame in the video using 'Space Bar', mark the areas that contain the object you want to detect using mouse and save it just by pressing 'S'. Utility will create the text file required fro training.

Utility can also be used to create sample images to be used for HMM training as well. If you are interested in HMM following http://www.bernardotti.it/portal/showthread.php?t=17777 has a good article on how to use HMM with OpenCV.

 

Refactoring Messy Code

Few days back I started to refactor some code of a project which I started few years back. Well actually I started working on that project during my second year first semester at the university. It is kind of a pet project which I started with one of my friends. When we started the project, our knowledge about best practices to be used when coding was near zero (I guess it is actually zero).

When I look back the source code of the project, it is like a hell. All possible bad practices are there in our code, very long methods (there is a one method doing some complex calculation which has more than 1350 lines :D ), code duplication, one class doing many things and the list goes on...

Well I can't blame my self for coding this kind of mess, since at that time I was just beginning my journey as a developer and didn't knew any thing about best practices. But I can't keep the code this way since it's readability is 0%; can you imagine reading a method with 1350 lines and understanding. Code has become more messy sine we have included lot of new features and requirement changes here and there. Any how we managed to deal with the code up to now, but now it is overwhelming.

Refractoring is not an easy task, we have to make sure that existing functionalities do not break as well as have to keep up with the new requirements as well.  As Martin Fowler describes in his famous book Refactoring: Improving the Design of Existing Code, there should not be any "Grand redesigns", recatoring should be an incremental process. This is going be be a good experience for me. Let's see how it goes.....

 

Craftsmanship and Ethics

This is nice presentation by Robert C. Martin posted at InfoQ. Here he talk about things that makes us professional. He talk about lot of important topics which help us to do better programming. If you are interested in programming this a going to be really really helpful for you.
In my point of view it is a MUST read for every programmer.
 

diGIT Magazine Launched


First release of the diGIT magazine was launched this month. It is a magazine dedicated for various stuff related to IT. This first release of the magazine is fairly large and rich in content ranging from introductory articles to advance stuff like Agent technology. So everyone from school children to university students can gain a lot from it.
You can view the online version of diGIT or you can download it in pdf format.
I also contributed to this magazine. My article is basically about how to start writing better code. I'm planning to write a series of articles on this topics covering various aspects of better coding practices and methods.
 

Alternative for JMS Receiver

Around 6 weeks back I was working on a project that used JMS. Application needed to receive messages through an ActiveMQ queue and then send those as SMS messages to a SMSC. This message sending happens as a batch and I needed to get batch size of messages from ActiveMQ inorder to send. I used JmsTemplate provided by Spring framework for this and used receive method to get messages from the queue.
Initially it was working fine, but later after more testing I found out that sometimes JmsTemplate's receive method do not return messages eventhough there are thousands of messages in the queue. I Googled, followed instructions given in many forum posts and ActiveMQ site with out much success.
Then one of my collegue Romith started searching source codes of some popular open source projects to see how they have used JMS receives. We were lucky... In Mule's code we found out the they have used JMS listners as a receiver. (May be mule people also have faced the same kind of problem as we were with receivers :) )
When we want to receive a message we initialise listener and get the message and then close that listener. We also developed simple class that can do the same, and it did the trick for us. Following is the simple class where we use JmsListerns to work as JmsReceiver.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jencks.amqpool.PooledConnectionFactory;

import javax.jms.*;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class JMSQueueReceiverImpl implements MessageListener {

private QueueConnectionFactory queueConnectionFactory;
private Queue queue;
private QueueConnection queueConnection;
private QueueSession queueSession;
private QueueReceiver queueReceiver;
private final Object messageReceiveWaitLock = new Object();
private MessageConsumer messageConsumer;
private Log logger = LogFactory.getLog(JMSQueueReceiverImpl.class);
private List receivedMessages = new ArrayList(20);
private int requiredMessages = 0;
private int RECEIVE_ALL_TIMEOUT = 1000;
private PooledConnectionFactory pooledConnectionFactory;
private static Map> missedMessages = new Hashtable>();
private static long totalJmsMessageConsumed = 0;
private static long totalJmsMessageReceived =0;
private static long connectionCreateCount = 0;
private static long connectionCloseCount = 0;


public JMSQueueReceiverImpl(QueueConnectionFactory queueConnectionFactory, Queue queue) {
this.queueConnectionFactory = queueConnectionFactory;
this.queue = queue;
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCreateCount + "] Creating the connection to the Queue [" + queue.toString() + "]");
}
queueConnection = (QueueConnection)pooledConnectionFactory.createConnection();
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
messageConsumer = queueSession.createConsumer(queue);
// doStart(queue);
receiveFromCacheIfExtraMessagesFetched(this.queue.getQueueName());
} catch (JMSException e) {
if (logger.isDebugEnabled()) {
logger.debug("Error while creating the connection ", e);
}
}
}


public JMSQueueReceiverImpl(PooledConnectionFactory pooledConnectionFactory, Queue queue) {
this.pooledConnectionFactory = pooledConnectionFactory;
// this.queueConnectionFactory = queueConnectionFactory;
this.queue = queue;
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCreateCount + "] Creating the connection to the Queue [" + queue.toString() + "]");
}
queueConnection = (QueueConnection)pooledConnectionFactory.createConnection();
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
messageConsumer = queueSession.createConsumer(queue);
// doStart(queue);
receiveFromCacheIfExtraMessagesFetched(this.queue.getQueueName());
} catch (JMSException e) {
if (logger.isDebugEnabled()) {
logger.debug("Error while creating the connection ", e);
}
}
}

private void doStart(long timeout) throws JMSException {
messageConsumer.setMessageListener(this);
queueConnection.start();
synchronized (messageReceiveWaitLock) {
try {
messageReceiveWaitLock.wait(timeout);
} catch (InterruptedException e) {
logger.info(e);
}
}
messageConsumer.setMessageListener(null);
}

private void doStop() throws JMSException {
messageConsumer.setMessageListener(null);
//queueConnection.stop();
synchronized (messageReceiveWaitLock) {
messageReceiveWaitLock.notify();
}
if (logger.isDebugEnabled()) {
logger.debug("Message receiving finished");
}

}

public Message receive(long timeout) {
try {
requiredMessages = 1;
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("[pre-single] success jms receive calls [" + ++totalJmsMessageConsumed + "]");
}
return receivedMessages.remove(0);
}
doStart(timeout);
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("[single] success jms receive calls [" + ++totalJmsMessageConsumed + "]");
}
return receivedMessages.remove(0);
}
return null;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
}
}

public List receive(long timeout, int messageCount) {
try {
requiredMessages = messageCount;
doStart(timeout);
totalJmsMessageConsumed += receivedMessages.size();
if (logger.isDebugEnabled()) {
logger.debug("[count] success jms receive calls [" + totalJmsMessageConsumed + "]");
}
return receivedMessages;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
}
}

public List receiveAll(long timeout) {
try {
requiredMessages = -1;
doStart(timeout);
return receivedMessages;
} catch (JMSException e) {
logger.error("Error while starting message receiving", e);
return null;
} finally {
try {
doStop();
} catch (JMSException e) {
logger.error("Error while stopping message receving", e);
}
}
}

public void closeConnection() {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++connectionCloseCount + "]Closing connection from queue [" + queue + "]");
}

try {
cacheIfExtraMessagesFetched();
try {
if(messageConsumer!= null){
messageConsumer.close();
}
} catch (JMSException e) {
logger.error("Error while stopping message receiver[consumer] ", e);
}
try {
if (queueSession != null) {
queueSession.close();
}
} catch (JMSException e) {
logger.error("Error while stopping message receiver[session] ", e);
}
queueConnection.close();
}catch (JMSException e) {
logger.error("Error while stopping message receiver[connection] ", e);
}
}

private void cacheIfExtraMessagesFetched() throws JMSException {
if (receivedMessages.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("Extra fetched message count is [" + receivedMessages.size() + "]");
}
String queueName = queue.getQueueName();
List queueMissed = missedMessages.get(queueName);
if (queueMissed == null) {
queueMissed = new ArrayList();
missedMessages.put(queueName, queueMissed);
}
while (receivedMessages.size() > 0) {
queueMissed.add(receivedMessages.remove(0));
}
}
}

private void receiveFromCacheIfExtraMessagesFetched(String queueName) throws JMSException {
List extraMessages = missedMessages.get(queueName);
if ( (extraMessages == null) || (extraMessages.size() == 0)) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Extra fetched message count [" + extraMessages.size() + "]");
}
while (extraMessages.size() > 0) {
receivedMessages.add(extraMessages.remove(0));
}
}

public synchronized void onMessage(Message message) {
try {
if (logger.isDebugEnabled()) {
logger.debug("[" + ++totalJmsMessageReceived + "] Jms message received jms-correlation-id[" + message.getJMSCorrelationID() + "]");
}
receivedMessages.add(message);
message.acknowledge();
if (receivedMessages.size() >= requiredMessages) {
if (logger.isDebugEnabled()) {
logger.debug("all messages had been received ");
}
try {
doStop();
} catch (JMSException e) {
logger.error("Error while stopping message receiving", e);
}
try {
Thread.sleep(5);
} catch (InterruptedException e) {
//
}
}
} catch (JMSException e) {
logger.error("Error while acknowledging ", e);
}
}

public void setRECEIVE_ALL_TIMEOUT(int RECEIVE_ALL_TIMEOUT) {
this.RECEIVE_ALL_TIMEOUT = RECEIVE_ALL_TIMEOUT;
}


/* public static void main(String[] args) {
BasicConfigurator.configure();

// PropertyConfigurator propertyConfigurator = new PropertyConfigurator();
// Logger logger = Logger.getLogger("sample");
// LoggerRepository loggerRepository = new Hierarchy(logger);
// propertyConfigurator.doConfigure("log4j.properties", loggerRepository);

org.apache.activemq.ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
PooledConnectionFactory pool = new PooledConnectionFactory();
factory.setBrokerURL("failover://(tcp://localhost:61616?connectionTimeout=1000&soTimeout=1000&wireFormat.maxInactivityDuration=1000&wireFormat.tightEncodingEnabled=false)?initialReconnectDelay=100");
pool.setConnectionFactory(factory);






Thread thread1 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("recharge.subscriber.response"))); thread1.start();
Thread thread2 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("transfer.sender.agent.response"))); thread2.start();
Thread thread3 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("recharge.agent.response"))); thread3.start();
Thread thread4 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("sap.reversedeposit.sms.queue"))); thread4.start();
Thread thread5 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("transfer.receiver.agent.response"))); thread5.start();
Thread thread6 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("checkreloads.agent.response"))); thread6.start();
Thread thread7 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("changepin.agent.response"))); thread7.start();
Thread thread8 = new Thread(new MessageReceiver(pool, new ActiveMQQueue("sap.deposit.sms.queue"))); thread8.start();

}

private static class MessageReceiver implements Runnable {
PooledConnectionFactory pool;
ActiveMQQueue activeMQQueue;
WaitLock waitLock;


private MessageReceiver(PooledConnectionFactory pool, ActiveMQQueue activeMQQueue) {
this.pool = pool;
this.activeMQQueue = activeMQQueue;
waitLock = new WaitLock();
}

public void run() {

for (int i =0; i < 100; i++) {
JMSQueueReceiverImpl listener = new JMSQueueReceiverImpl(pool, activeMQQueue);

for (int j =0; j < 20; j++) {
listener.receive(10);
}
listener.closeConnection();
try {
synchronized (waitLock) {
waitLock.wait(200);
}
} catch (InterruptedException e) {
e.printStackTrace(); //todo implement the method
}
}

}

private class WaitLock {
private WaitLock() {
}
}

}*/
}

We have used Jencks ActiveMQ connection pool here. You can download if from codehaus here.


, , ,

 

OpenXava - Easiest way to create DB driven websites in Java

If you are a someone interested in computer programming, at some point of time you may have created a DB driven website. If you have done that you may know how difficult it is to create even a small website. Even with code generation facilities provided by IDEs and ORM tools like Hibernate you have to do quite a lot to get your web app running.
This is where OpenXava (OX) comes in handy. It is really easy to create DB driven web app using this framework. With OX to create Db driven web app only thing you have to do is to define your business entities. Yes, that is the only thing you have to do, and OX will create you nice AJAX driven website with all CRUD operations implemented and also with reporting capabilities with PDF and Excel. It is amazing right....

How much time do you think will take to create above simple web app?, an hour... Actually it only took me 10 minutes to create it with all those features, what I did was implemented simple pojo class Customer and everything else was done by OX.
OX provides you lot of customization capabilities as well. So I think this is a good time saver tool.
Download OX from here and see for your self....
 

Wishing you a Very Happy New Year


Wish you all a very happy new year.
May all your dreams come true in this wonderful year....
 

Tribune to Heros

Tribune to Heros
We will never forget the sacrifices you made to protect our country....

Subscribe


Get Google Toolbar Button

Enter your email address:

Delivered by FeedBurner

Blog Archive