Monday, March 31, 2014
Now I am serious about Design Pattern
I know it is kinda late. I have been writing program following a code structure defined by some other team many years back and somehow I did not go find out what are the design patterns.
As you all know design patterns are meant to solve common programming problems in the area of program's stucture, program's behaviour and etc. I have studied all the design patterns before but without really using them, I do not rally remember them too much. The problem is whether is if design pattern really needed in the developer's environment.
Recently I found out that actually I did use design pattern without me knowing about it. LOL. What I can identify now is the Bridge Design Pattern where in my code I created a lot of interfaces to group all the commonly used methods from different classes together. For the detail explanation of the Bridge Design Pattern you may just read about it here ---> Bridge Design Pattern
In fact, I have also used the Factory Design Pattern. This helps optimize the program's memory consumption by reducing the number of times of "instantiation". For details you may just read up Factory Design Pattern.
By the way there are something called "Architectural Pattern" aslo. This is useful for higher level end to end solution.
Saturday, May 5, 2012
BEWARE of asterisk!
Some sharing.
I was about to replace certain string in a specific file in all directories in a AIX machine. We have a Perl script file to perform this action. All this while it has been running fine but not today.
After some troubleshooting i quickly discovered it is due to: the string that we are going to replace contains an asterisk(*) which causes the whole script not working properly.
Very shortly my colleague found a solution, which is to 'escape' the asterisk(*) symbol by putting a backslash(\) symbol right before the asterisk(*) symbol so that when the script is running it will escape the *
Before (this will give error)
perl -p -i -e 's/12345*9/abcde/g' `find ./ -name somefile
After (this will solve the problem)
perl -p -i -e 's/12345\*9/abcde/g' `find ./ -name somefile
I was about to replace certain string in a specific file in all directories in a AIX machine. We have a Perl script file to perform this action. All this while it has been running fine but not today.
After some troubleshooting i quickly discovered it is due to: the string that we are going to replace contains an asterisk(*) which causes the whole script not working properly.
Very shortly my colleague found a solution, which is to 'escape' the asterisk(*) symbol by putting a backslash(\) symbol right before the asterisk(*) symbol so that when the script is running it will escape the *
Before (this will give error)
perl -p -i -e 's/12345*9/abcde/g' `find ./ -name somefile
After (this will solve the problem)
perl -p -i -e 's/12345\*9/abcde/g' `find ./ -name somefile
Sunday, March 11, 2012
Strange issue on JAR???
Wondering if anyone out there experience this before.
I have this program calling a external web service. So i built the client classes to consume it.
After some time the web service contract/schema had changed, i needed to either change the content of the classes or rebuild the client classes again. Usually i prefer a rebuild as this will be done by the generator with very minimum effort.
So i rebuilt the client classes. Everything worked fine in the Staging/Testing environment until the production rollout day.
Exactly the same JAR, but not working. I drilled down into which line that caused the havoc. Strange thing is that the program was not able to read the particular web service client classes. I then checked if the client classes were included in the JAR and they were there! Their were at the right path too! What happened?
No choice i needed to get this done asap. I moved these classes from one folder to another folder, ofcuz by using the refactor function. This was just a blind hit and guess what, it works!!!
This may give you an idea the next time you are facing exactly the same weird issue!
I have this program calling a external web service. So i built the client classes to consume it.
After some time the web service contract/schema had changed, i needed to either change the content of the classes or rebuild the client classes again. Usually i prefer a rebuild as this will be done by the generator with very minimum effort.
So i rebuilt the client classes. Everything worked fine in the Staging/Testing environment until the production rollout day.
Exactly the same JAR, but not working. I drilled down into which line that caused the havoc. Strange thing is that the program was not able to read the particular web service client classes. I then checked if the client classes were included in the JAR and they were there! Their were at the right path too! What happened?
No choice i needed to get this done asap. I moved these classes from one folder to another folder, ofcuz by using the refactor function. This was just a blind hit and guess what, it works!!!
This may give you an idea the next time you are facing exactly the same weird issue!
Best way to remove MQRFH Header (WMB)
I have tried many approaches just to achieve this. My goodness each approach is so unstable. It may work in environment A but then somehow does not work in environment B.
With the help from a more experienced colleague, the optimum solution for that seems to be:
1) Set the Message Domain as XMLNSC for MQInput Node.
2) Create a Compute Node then write your ESQL as follows:
CALL CopyEntireMessage();
SET OutputRoot.MQRFH2 = null;
Done! It's never been so easy. Fuck i wasted much time in this! Should have known this colleague long time back.
With the help from a more experienced colleague, the optimum solution for that seems to be:
1) Set the Message Domain as XMLNSC for MQInput Node.
2) Create a Compute Node then write your ESQL as follows:
CALL CopyEntireMessage();
SET OutputRoot.MQRFH2 = null;
Done! It's never been so easy. Fuck i wasted much time in this! Should have known this colleague long time back.
Tuesday, March 1, 2011
WMB It's best to set BLOB as the parser for message containing MQRFH2 header
I was struggling with this message(XML) with MQRFH2 Header.
I have tried the MRM Header, the drawback is that you got to choose a schema, which makes it less flexible. Also the parsers being selected at runtime (printed in the mqsitrace log) are not consistent! Still puzzling.
Setting parser as BLOB in the MQInput node solved my issue. Without making any further message format conversion, you can read the xml using XMLNSC parser anytime anywhere.
I have tried the MRM Header, the drawback is that you got to choose a schema, which makes it less flexible. Also the parsers being selected at runtime (printed in the mqsitrace log) are not consistent! Still puzzling.
Setting parser as BLOB in the MQInput node solved my issue. Without making any further message format conversion, you can read the xml using XMLNSC parser anytime anywhere.
Monday, September 27, 2010
Transfer message with RFH header from one queue to another queue
I have this simple java program transferring message with RFH header from one queue to another queue in bulk.
First time it failed due to the program failed to maintain the RFH header during the transfer. It read the message in STRING format and then put the message back in the destination queue.
After that i changed this by sending the MQMessage directly to the destination queue. This works.
First time it failed due to the program failed to maintain the RFH header during the transfer. It read the message in STRING format and then put the message back in the destination queue.
After that i changed this by sending the MQMessage directly to the destination queue. This works.
Thursday, September 9, 2010
java.sql.Date not working on WPS 6.2?
I had this program reading database table column as java.sql.Data type. Well it failed to read this when running from the WPS AIX server. Funny thing is it was fine when i was testing this program from my local WPS server runtime. In application log the column data type is recognized as java.sql.Timestamp. So i have to change to program to read Timestamp instead of Date.
Subscribe to:
Posts (Atom)