Sunday, January 29, 2012

Using Groovy to receive and send mail

In ongoing integration project we had to add e-mail notification (by Zawinski's law). For development, we are using well known Apache James Server. Setting it up was piece of cake but for initial testing it is good to test send and receive functionality. That can be done in numerous ways, one is to use Groovy. Because we use Java to send e-mail, using Groovy for testing, makes perfectly sense. To send e-mail one can make use of ant task for sending mail from Groovy. Script is straight forward and inspired by this ONJava article. There is one caveat though, one must load javax.mail library via systemClassLoader. Putting it all together it looks like self explanatory script below: To read e-mail, Groovy can also be handy, but script is not one-liner as one above. It is actually rewrite of some Java class found on internet. Use both scripts as you like.

Monday, January 16, 2012

How to speed up 802.11n wireless

This is first my first not development related post but it may help you develop faster :-)
If you recently bought new router, compliant with 802.11n standard, you may have been disappointed by getting only 54 Mbit throughput. That is, router appears to work in 802.11g mode. If you use your router for DLNA or HTPC, speed may be of great importance. To get this speed, your computer (laptop) must be also 802.11n compatible but that is something well known. There are others things that may obstruct you. My router was configured to support TKIP or AES (TKIP+AES) encryption and my windows machine used TKIP. According to Intel TKIP is not supported for 802.11n. They say:
If you use these encryption methods (for example, WEP, WPA-TKIP), your data rate will drop to 54 Mbps.

For me it has worked. I have just changed my security setting from WEP-Personal TKIP -> AES and speed was up to 72 Mbps.  If this didn't help you there is some other stuff that you can check out also.

Update 29.1.2012:
Recently I have found out that my wireless adapter driver was set up to use 20MHz bandwidth only. I have changed this and immediately get a connection with full (theoretical)  150 Mbps. That should make synchronization between notebook and home pc even faster.  Changed driver setting is like one on the image below:


While I was on it I have changed my router and adapter power level. After little experimenting I have found out that I need only 25% percent of router power to have good signal. I have also changed adapter power level to Medium (Transmit Power -> 3. Medium). Updated router setting via Advanced Wireless Settings screen is as shown on image below:

I suggest to everyone to change power level at least at their laptops. Why pollute environment with high level radiation? In most cases wireless router is in the same (or next) room, power level should reflect router proximity (low distance -> low power).