My Personal Online Recycle Bin
You may find something useful here...........

Tuesday, March 06, 2007

Asynchronous Search JMS with MDB

It is a common scenario where there are 2 application communicate through a JMS Queue. And majority of time, one application will be web application search module.

And the process flow will normally as followed:
1) put request on sending queue
2) expect response from receiving queue

Since JMS is designed to be asynchronous, it is not good to have the synchronous servlet waiting for response from receiving queue while holding the resource.

What i mean by synchronous servlet is a single servlet put request and waiting for response in a doGet or do Post method. In this way, the server resource will be holding while still waiting for the response. If the response take long time to return, this eventually will lower the application server performace.

The solution in short :
1) Servlet to put request on sending queue and return to jsp after put request
2) In JSP, using either META tag or javascript to refresh the page every n second
3) When page is refresh, send request to another servlet that check the queue/DB for the response.
3a) Can also used MDB to listen on receiving queue, and insert record to DB directly after receive response. Then when servlet check can directly check the db.
4) If response is still not yet ready, return back to the jsp again
5) If response is ready, forward to another jsp that display the result.

For Full Details, please visit the Asynchronous queries in J2EE

Saturday, February 03, 2007

Remote Debugging with JPDA

Recently I just found out there is something called JPDA(Java Platform Debugging Architecture) that can help debug much efficient. Debugging web application was much simpler and more convenient when using JPDA. I will leave a note since this is my recycle bin. Wahahaha....

I like the concept of Object Oriented, that why i also like to reuse. Since someone else have already wrote some guide on how to debug using JPDA, thus I will just put the link here for reference.


Configuring Eclipse for Remote Debugging

Monday, August 14, 2006

可恨青龙偃月刀........

Today, I so happen to heard about the following poem..

可恨青龙偃月刀,华容道上未诛曹。至今留得汗雄种,逼迫诗人坐船艄。


Found it quite interesting, so I did a search and found the full story..

有一年,郑板桥到泰州去赶考,没钱叫船。靠两条腿驴子吧,怕误了考期。他就费了点口舌和酒钱,得着船夫的同意叫他坐在后舱内。船夫对他说:“在船上不要乱跑,这船是城内曹公馆独雇的,说定不带外人,叫舱中三位少爷知道了,我挨骂事小,还要把你赶出去的。”
郑板桥坐在舱里觉得孤单,就出来给船夫说话闲谈间,才知道舱内三位少爷,也是去泰州赶考的。郑板桥凑近舱壁缝一看:这三位的气概倒也不俗。这时,听见一位少爷说:“大哥二哥,今天不读什么文章了,你们看晨曦映水面,清风徐来,两岸树木葱茏,景色如画,岂可无诗?今天我们作诗,乐一乐,借此又可作为纪念,也算我们不虚此行,如何?”大公子不同意,说:“今青云在望,何舍大道而勿由,以吟风弄月消千金之一刻乎?吾弟休矣!”“赞成!赞成三弟的话不错!大哥,你也太固执了,对景当歌,古人也有名训哩!”这样辩论了一会儿终究作起诗来了。他们磨了墨,就互相踱起步来——六只脚踏船板,通通煞是好听,一会儿哼一会哈,墨都干了,还没有哼出一个字来。郑板桥见他们酸得令人作呕,顺口吟出四句诗来:“可恨青龙偃月刀,华容道上未诛曹。至今留得汗雄种,逼迫诗人坐船艄。”
这三位少爷一听,可就火了,叫船家把吟诗人叫来。二少爷一看是一个穷酸,倒还斯文,便问:“你这人怎么这样可恶?你搭我们的船,我们不与你计较,你为何骂人?”郑板桥说:“今天听三位高吟,不觉随口乱扯了几句,实在不懂得骂人不骂人”。大少爷说:“既是读书人,都为孔门弟子,一家人也,不必计较矣,你既能诗,可当面即作一首,诗成则罢,不然请离此船。”郑板桥说:“可以,请出题,哪一位代我记下来。”三少爷说:“我录,快!快!”二少爷说:“以到泰州为题。”板桥接着做诗:“蜉蝣一小舟,哧嗤缘水流。窿咙一声响,霍踱到泰州。”郑板桥说完,三少爷在纸上写的只有每句的下三个字,共十二个字,那上面的八个字,谁也不认识。这时候,三少爷才知道这穷酸不是平庸之辈。不一会儿,郑板桥就高踞首座了。

Sunday, July 23, 2006

PADI Certified Open Water Diver

YES...Another Certification..

PADI Certified Open Water Diver...

Hahahaha...

This saturday, I just received my PADI certified Open Water Diver Card. Finally, the card reach to me after 2 month waiting.

Below is the card image:





Now, I am waiting for the next diving trip.....Hopefully it will be a joyfull and relaxing trip...Wahahaha...

Sunday, June 25, 2006

Exception Handling in java

This friday, One of my friend did sent me a link titled as "Exception-Handling Antipatterns". As opposed to those normal article that teach you how to handle exception in java, instead it show you what is the wrong pratice or mistake that offen did by most fresh or even experienced java developer.

I found it quite usefull and interesting, thus I would like to share it with you. Here is the "Exception-Handling Antipatterns" from java.net.

Beside that, I also found another article from the same site that talk about 3 simple rule of exception handling.

1)Be Specific
2)Throw Early
3)Catch Later

Full artcile can be found from "Three Rules for Effective Exception Handling".

Sunday, June 11, 2006

Only one single DataModelList in one form

Those who are familiar with jsf, should have been very familiar with DataModel. DataModel allow developer easily get the selected data(object) from a DataTable which save a lot of work.

If you are interested at a DataModel example, you may refer the following link for example from ibm developer work.

JSF for nonbelievers: The JSF application lifecycle

But you may not aware that only one single DataModel is only allow in one form. If more than one DataModel in a single form, then both DataModel will not showed up. The only solution is to used 2 separate form for 2 DataModel.

Thursday, May 25, 2006

Using xdoclet to generate hibernate one to many relation

How to generate one to many hibernate relation with xdoclet.

I begin with looking at the sample availabe in the internet and ebook. Both of the resource bring me to something like this...

/**
* @hibernate.set cascade = "save-update"
* lazy = "true" inverse = "false"
*
* @hibernate.collection-one-to-many class = "com.xxx.yyy.ggg.vo.ManySide"
* @hibernate.collection-key column = "fk_OneSide"
*/
public Set getXxxSet() {
return manySet;
}

public void setXxxSet(Set xxxSet) {
this.xxxSet = xxxSet;
}


I tried it out. But it give me the following error:

Reason: java.lang.RuntimeException: no element tag deined in class YYY for xxxSet

Then i tried to solved it using a lot different way. After one day searching on my best friend (google). Finally i come to this url that solved my problem easily.

The solution is just to remove the "collection" word. The solution is as follow:

/**
* @hibernate.set cascade = "save-update"
* lazy = "true" inverse = "false"
*
* @hibernate.one-to-many class = "com.xxx.yyy.ggg.vo.ManySide"
* @hibernate.key column = "fk_OneSide"
*/
public Set getXxxSet() {
return manySet;
}

public void setXxxSet(Set xxxSet) {
this.xxxSet = xxxSet;
}


The problem is due to the fact that i am using xdoclet2 from maven instead of xdoclet1 from sourceforge. Thus they have different syntax.