Monday, January 17, 2011
Issue on starting RabbitMQ 2.2.0 After Installation via MacPorts
Did more digging and found out that the daemon generated by MacPorts after it installed RabbitMQ was getting spawned when my computer starts up. But the problem is it's using localhost as the domain instead of mycomputername. When I try to kill that spawned process, rabbitmq automatically re-starts and now using the node rabbit@mycomputername. So I can now use rabbitmqctl command and query the rabbitmq server. To permanently fix the issue, I have to remove the plist file org.macports.rabbitmq-server.plit which defines the start/stop behavior of rabbitmq-server which is registered as a global daemon process that will automatically kick-off when my computer boots up.
After removing the plist file, and manually starts rabbitmq by typing sudo rabbitmq-server, I no longer see any errors. I wasn't sure why MacPorts generated that plist file that always uses localhost as it's domain instead of mycomputername when it starts rabbitmq-server initially.
If your erl_crash.dump file contains the string below you might have the same problem. Either check to see if you have configured your /etc/hosts file properly or that you are having the exact same problem I just came across with.
no_hosts_file
'Warning: No HOSTSFILE specified!'
address
'Warning: No NAMESERVER or RESOLVFILE specified!'
Glad I can start playing around with RabbitMQ!
Tuesday, November 30, 2010
Working as a Consultant
Developing a system in-house for a client makes the development and management effort very interesting but I find there are two most critical things that needs to happen before a single code is written as shown below.
- Validating verbal and written client's development platform
- Knowing how your client's think, how your client's work, and what makes them happy.
Internationalizing Java Web Applications Part I
4. Database Internationalization Support
6. i18n Bundle - Property Files and Data
10. The Locale class
OS and MS Office Language Settings
1. OS Server
The operating system should have been installed with the languages the users are interested in. At least the english (en_US) language and make it the default language. You can check what the OS supports by checking the Regional and Language Options if your server is Windows based. There you can see Standards and Formats of the currency, number and time from the Regional Options tab. While the Languages tab shows the option to choose what Text Services and Input Languages to use and allows one to install East Asian Language Support and this is really important specially if we are working with Chinese, Japanese or Korean language.
Now for an Application Testing Environment that supports many different languages, the server can have the English [United States] setting from Regional Options and leave the other properties unchanged. If Japanese, Chinese or Korean or any East Asian Language is needed for the application, then the East Asian Language Support must be installed.
To test if the language settings are correct, drop a text file that contains data with the language of interest to the server. Open the file. If the data is in Chinese, then the text characters should show up as Chinese characters. Otherwise, the language settings aren't right.
2. OS Client
On the client side, there must also be Language settings that needs to be done. The OS should also have come installed with other languages. But the East Asian Language is by default not installed. This must be installed if Japanese, Chinese or Korean needs to be supported.
3. Microsoft Office
Apparently, Microsoft Office needs to be tweaked to properly display East Asian characters. No tweaking is necessary for other languages. Just go to Microsoft Office Tools and click on Microsoft Office Language Settings. There you can enable other languages for proper viewing of data.
Database Internationalization Support
All major database products supports internationalization. It should be able to support Unicode characters or the literal character of that language (by using the prefix 'N' when inserting data into the database).
I18N Bundle
All internationalized app have i18n bundle which is used for displaying the appropriate label, description or error message to the application. This bundle is basically a jar file containing all the supported languages or locales. The files in that jar are properties file of the form I18N_locale.properties (i.e. I18N_en_US.properties for English US). So each properties file is composed of a key/value pair. If this is done right, then you avoid a lot of translation issues. The number of keys from the default locale, say en_US should match the number of keys in the other locales. The value for each key must be translated for its target locale.
Thursday, March 4, 2010
Atlanta ITARC 2010
He didn't talk about technologies and trends but mainly focused on how should an enterprise architect treat his relationship with the business people and how he should realize things that matters most to the business. Here are some concepts he shared worth noting.
10 Critical Success Factors For Enterprise Architecture
- Seek expert help to setup an Enterprise Architecture practice
- Have Executive Sponsorship
- Clear Roll-out Plan
- Strong Internal Program Leadership
- Focus on Enterprise Architecture Adoption Process
- Laser-focus on business value
- Leverage the wider data team
- Automate the data collection process
- Market your success internally
- Flexible Enterprise Architecture Technology to enable successful Enterprise Architecture
- Focus on what is important to the business NOW
- Align with allies, don't waste time with disbelievers
- Seek funded, complex initiatives
- Careful when "moving cheese". Consider politics in play.
- Create sustainable process
- Publicize your results
- Recognize stakeholder needs
- Avoid being the bottleneck. Federate and participate.
- Leverage established best practices
- Implement incrementally
Tuesday, February 9, 2010
Executing MySQL Scripts in Batch Mode
My *.sql files are basically scripts that builds database tables.
Here's what I've done;
################################################################################
#!/bin/sh
# Reads the specified directory and traverses for the sql script files.
# The first argument($1) is the target directory to be searched.
#Read the files in the directory and generate the table creation statements separating them using the semi-colon delimiter
# If there are sub-directories, they will be traversed and all files ending in '.sql' will be processed
source_queries=""
source_command="source "
echo "argument passed $1"
for file in $(find $1 -type f -iname '*.sql'); do source_queries="${source_queries}${source_command}${file};"
done
# Uncomment to printout generated queries/statements for debugging purposes
# echo "printing statements generated ${source_queries}"
# Connect to the database using the 'stratus' database and execute the query statements generated
# This can be run on the background as well
echo "Executing database tables creation scipt......."
mysql -u myuser --password=mypassword --database=mydatabase -e "${source_queries}"
echo "script completed...."
#################################################################################
Say if there's 1 script file with filename create_person_table.sql under the target directory /opt/db_scripts the resulting mysql command would look like this
mysql -u myuser --password=mypassword --database=mydatabase -e "source /opt/db_scripts/create_person_table.sql"
If there are multiple sql files the clause on the '-e' option would look like this
mysql -u myuser --password=mypassword --database=mydatabase -e "source /opt/db_scripts/create_person_table.sql;source /opt/db_scripts/create_employee_table.sql"
Saturday, February 6, 2010
JUnit
To illustrate this further, lets consider the sample code below. It's main purpose is to show how the methods above behaves when the test case is run.
Say we have this test class:
1.public class TestPerson extends TestCase{
2. private Person person;
3.
4. protected void setup(){//create Greg
5. person = new Person("Greg");
6. }
7.
8. protected void tearDown(){
9. person = null;
10. }
11.
12. public void testCreateChild(){
13. person.createChild("Nimfa");
14. }
15.
16 public void testMarrySomebody(){
17. person.getMarriedTo("Laila");
18. }
19.}
When this test case is run, here's what's going to happen:
1. At line 2, the person variable is declared and initialized
2. At line 4, setup() method is called
3. At line 12, testCreateChild() method is called (assuming this is the first method called)
4. At line 8, tearDown() method is called
5. At line 2, the person variable is declared and initialized again
6. At line 4, setup() method is called is called again
7. At line 16, testMarrySomebody() is called
8. At line 8, tearDown() method is called
After code execution, Greg will loose a child names Nimfa then get married to Laila instead of having both the child and getting married. Sad story....
Here's the explanation. In a nutshell, the number of test methods we have, in this case two(testCreateChild() and testMarrySomebody()), is directly proportional to the calls of the setup() and tearDown() methods and to the declaration and initialization of the member attributes. The variable person will be instantiated again with a new Person object but with the same value which is 'Greg' for each method loosing the previous state of the child created. Greg will always end up getting married and not having a child.
If the intention on line 5 is to create an object which has a state consistent across all test methods, then it is a problem, since JUnit will basically create a new object per test methods. Object state maybe different from each test methods. The best approach would be to not use the setup() but instead initialize the object in the test method itself. So the object(s) initialized at the setup() method is never reused to the rest of the test methods. The tearDown() method is not necessary since it's just destroying the created object unless, a specific resource(i.e. database connection, etc.) needs to be released and should be called here.
Tuesday, February 2, 2010
Ten Commandments of Egoless Programming
Here are the 10 Commandments of Egoless Programming, my friend willingly shared.
1. Understand and accept that you will make mistakes.
2. You are not your code.
3. No matter how much "karate" you know, someone else will always know more.
4. Don't rewrite code without consultation.
5. Treat people who know less than you with respect, deference, and patience.
6. The only constant in the world is change.
7. The only true authority stems from knowledge, not from position.
8. Fight for what you believe, but gracefully accept defeat.
9. Don't be "the guy in the room."
10. Critique code instead of people-be kind to the coder, not to the code.
Friday, January 8, 2010
Installing Solaris 10 Software Companion CD from ISO Image
1. Type the command lofiadm -a /export/temp/software.iso. This command creates a block device from a file which can be mounted. The block device will look something like this /dev/lofi/1.
2. Mount the block device by typing this command mount -F hsfs -o ro /dev/lofi/1 /mnt. We are mounting a file system of type hsfs(High Sierra File System) which is basically a representation of our iso image (compact disc). We can also use the cdfs(Compact Disc File System) if the file is being mounted from a cdrom. The ro option basically means its a read-only.
3. You can install one package at a time, but for the purpose of this demo, I'm gonna install all of the packages. Next step is to create an admin file say on this path /var/tmp/admin. The admin file should be created by root user. It contains the following:
mail=
conflict=nocheck
setuid=nocheck
action=nocheck
partial=nocheck
instance=overwrite
idepend=nocheck
rdepend=nocheck
space=check
Now this will install the packages without having the user interact with the package installation.
4. Change directory to the location of the software companion packages relevant to your architecture. In my case I'll be installing it on a Solaris 10 OS. After changing to that directory it should look something like this /mnt/Solaris_Software_Companion/Solaris_sparc/Packages.
5. As a root, execute this command pkgadd -a /var/tmp/admin -d /mnt/Solaris_Software_Companion/Solaris_sparc/Packages. The -a option overrides the default admin file with the one we just created.
6. Once it executes, it will display all the available packages to be installed and will asks you to install a package or all of the packages. Choose 'all'. Installation will proceed to run.
Friday, January 1, 2010
Installing CouchDB Version 0.10.1 On Fedora 4
working online and offline. With its interesting characteristics, I decided to install it on my Fedora machine.
Here are the dependencies I've installed (assuming everything was a downloaded source):
1. curl-7.19
2. SpiderMonkey - js-1.7.0
3. ICU - icu4c-4_2_1
4. Erlang OTP - otp_src_R13B03
5. autoconf-2.13
Somebody had provided a script to properly and easily wire SpiderMonkey with CouchDB as can be seen from http://74.125.47.132/search?q=cache:http://dt.in.th/2008-03-03.spidermonkey-linux.html. This is our script:
#!/bin/bash
if test "$USER" = root; then
wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz -O- | tar xvz
cd js/src
make -f Makefile.ref
mkdir -p /usr/include/smjs/ -v
cp *.{h,tbl} /usr/include/smjs/ -v
cd Linux_All_DBG.OBJ
cp *.h /usr/include/smjs/ -v
mkdir -p /usr/local/{bin,lib}/ -v
cp js /usr/local/bin/ -v
cp libjs.so /usr/local/lib/ -v
else
echo "You must be root. Try sudo $0"
fiTo ensure that CouchDB will compile properly, use the options --with-js-lib and --with-js-include when installing it. Type the command couchdb to run it. Then try to run this command curl http://127.0.0.1:5984/. You should see something like this {"couchdb":"Welcome","version":"0.10.1"} as the response. This means that the database was successfully installed.
Futon is a great web interface to the database. Be sure to run all tests from Futon. If the URL used to access Futon is say http://localhost:5984/_utils, there are 3 tests that will fail - oauth, replication and security_validation. This is a known issue for some common network configurations. My setup is basically a Windows XP accessing thru Futton the CouchDB server instance which is installed on a Fedora machine. Both machines are connected via a router without any DNS configurations. Whatever the network configuration is, this URL will always work and all tests passes - http://127.0.0.1:5984/_utils.
I prefer a different ip address used to access Futon so I went ahead and updated two configuration files which are default.ini and local.ini. The settings from local.ini will override the default.ini. Depending on your installation of CouchDB, these files can be found at /usr/local/etc/couchdb directory. Change the binding address to suit your needs.
Tuesday, December 22, 2009
Checksum App for Windows is a Worm!
Saturday, November 14, 2009
Internationalizing Numbers and Dates in Java
Thursday, October 15, 2009
Working with Deleting/Updating a Set In Hibernate
Wednesday, September 30, 2009
JFreeChart LegendTitle Font Change
Monday, July 20, 2009
iPhone Mobile Camp Atlanta
Tuesday, May 26, 2009
Integrating Author It Compiled Documents with Strutsonlin


The import of the bean taglib is needed to extract the SessionData bean which lives in the session and get the onlineHelpCode string value from it and plop it to the SRC element. It is important that this file is located where the jsp files are.
Tuesday, May 12, 2009
Using Chain of Responsibility Pattern




Wednesday, May 6, 2009
When do we say its the right tecnology to use?
It's always a challenge to marry the right technology with the right requirement that would produce a fluid, solid application. One-Stop-Shop approach of resolving business issues is no longer becoming relevant in the global IT market. You pay so much that without realizing only a fraction of the features provided by that technology is only essential to what the business requires. A lot of companies now are resorting to only "get what you need" and "pay what you only need" mentality. This is where customization comes in. The beauty of customization is it delivers the solution that the problem it exactly expects. This strategy relieves companies from paying too much.
When the curse of overengineering starts to sink in, its a manifestation of wrong implementation. But what is overengineering? It's a combination of technology misuse and irrelevant complex implementation. If the implementation looks simple and it solves a business need then we just answered the first question above.
The danger comes when technology features molds how the application should behave. This deviates the application from concentrating into its prioritized functionalities and might deliver features not needed at all. Scope creep is the twin evil of this situation. Looking at it at the brighter side, this is the best opportunity to step back and review the requirements and correct and refine the implementation.
Implementing User Sessions for Crystal Reports Java SDK
1. Log on to Crystal Report Server
You call the metod CrystalEnterprise.getSessionMgr() which returns you an object of type ISessionMgr. From there call the method of the returned object below which returns an object of type IEnterpriseSession.
logon(String userName, String password, String ceServerName, String secEnterprise);
2. Create Logon Token
The IEnterpriseSession has a method getLogonTokenMgr() that returns ILogonTokenMgr. Call the method below to get the logon token string.
createWCAToken(String clientServerName, int validMinutes, int validNumLogon);
The validMinutes parameter represents how long do you want to maintain the session and the validNumLogon represents how many logons the client can perform in one session within the given valid minutes.
3. Logon to Crystal Server with Token
Call the method below from the class ISessionMgr and pass the logon token string that was previously generated. This returns to you a new IEnterpriseSession that has the token. All transactions will then use this session object until the minutes or log on counts are exhausted.
logonWithToken(logonTokenString);
Of course, somehow this session will expire later on and the client application need to reconnect. The good news is you just have to follow the same steps. On the other hand, if the session is still valid and somehow the application needs to reset the connection, always check for the session if it already expired. If it is, release the token and logoff with the following sequence then proceed to steps 1 through 3 again.
releaseToken(logonTokenString); // called from ILogonTokenMgr
ceSessionWithToken.logoff(); // called from IEnterpriseSession with token
ceSession.logoff(); // called from IEnterpriseSession without token
This approach will be very useful for batch processing. You want to keep the pipe full while the report server is processing. With on demand request report processing, you don't want to keep a session open for a long time.
Friday, May 1, 2009
Java Multithreaded Web Service Performance Tips




Tuesday, April 28, 2009
Jakarta Commons Net API
Jakarta Commons Net(JCN) Java Library is just one of those open source projects I've enjoyed working with. Specially its FTP API. Which is gonna be the focus of this discussion.
I've implemented a component that uses this library in a Web Service environment which basically connects to a remote FTP service then iterate through the list of directories, process the files and handle the reply codes properly. The list of files may go to several thousands.
Here are the things I found really useful from JCN.
1. It automatically issues a new PORT command to the server so we don't have to worry about manually setting the port for different platforms (Unix, Linux, Windows, Mac, etc.) when connecting. Also validates data connections to client to ensure the request had originated from the intended host. We don't want our application deal with strangers eh?
2. It allows you to page through the list of FTP files. I think this is an awesome feature! From my previous project the list of files can span to several thousands. But through FTPListParseEngine class I was able to page through the files and process them in smaller chunks. This is a great performance boost. We only load the ftp file objects we currently need. Creating this objects are expensive. We keep the metabolism of an application running this way and saves us the evil of bottlenecks.
3. Provides very easy to use and effecient way of handling FT Reply Codes. The codes are basically messages passed by the FTP Server indicating if the request was processed successfully or not. There are about 49 codes which you can check at this link http://www.turboftp.com/turboftp/manual/TURBOFTPFTP_Server_Reply_Codes.htm . After a command is issued to the server, the server returns an int value representing the code. Just capture this code and apply the behavior you want to happen in the application.
This is a great way to isolate specific ftp issues and handle it properly so the application can still function, say even if the FTP service is down. Or if your previous request gave a code that identifies your request as not processed, you can resend it upto a certain number of times until you mark it failed. There's no point sending an ftp command or request if the data connection is not established, as shown below.

Also shown below is an example of flagging the reply if its ok or not with their matching simple behavior implementation.

I can see no reason why JCN can't be used. It provides the necessary security and performance gain we need. Plus it provides you an elegant way of handling FTP Reply Codes that you can use to manipulate the behavior of an application consuming an ftp service. Documentation is well written too.




