Thursday, February 24, 2011

JMS and Async, Dont mess with it

JMS stands for Java Message Service which is an API which is used by middle ware service providers such as ActiveMQ, JBoss MQ, Rabbit MQ etc etc. Its main purpose is to allow disparate systems to communicate based on a common platform. Which means that if i have my front end written in .Net and my back end written in Java for example one way of communicating between the two (other than Webservices etc) is to use a JMS provider in a publisher-subscriber or peer-to-peer configuration.

In our own project we have used JMS but not to communicate between two disparate systems but to get the asynchronous capability integrated to our application. What we do is push the message into a queue and get along with the rest of the business process. But from what i see this is not the correct way of achieving this. Of course at the end of the day we have achieved asynchronous behavior but not in the right way. A solution just came to light a few months back with the release of Spring 3. Spring 3 provided an implementation allowing asynchronous capability with the @Async annotation. I will not go into the details of this feature as it is very well explained here.


I have changed the previously JMS oriented code which mimicked the asynchronous capability and introduced Spring's Async implementation as i felt it was much cleaner and reduced all handling i needed to do with onMessage(),Connection Factory and the rest of the code needed to deal with JMS queues and topics.


Wednesday, February 16, 2011

Learn, Respect, Triumph

This post is for all the new developers out there coming to the industry. Take a look at the Title of this post. Ok read it again. Ok Again. Alright now lets get going. I wanted to post something to all the new developers that come into the field of IT. I myself am not a veteran software engineer, i count a little over 4 years of experience. Wanted to share my thoughts about the new guys who come in. I see them and remember myself 4 years back and wanted to share some insights.

I often see new people who come in, fresh and pumped up to work. This is just great to see, reminds me when i was first entering the world of IT. Few things i noted which i myself was a victim back in the days are the ones i am going to go through within this post.

 Learn

I see few people these days who just enter the field of IT and they expect to work on the latest technology, with the latest frameworks and what not. This is great and there should be that hunger for technology but i would like to point out that you will not always get the chance to work on a project with all the latest technology. You would probably blame the company for not adapting to the new trends. Ok take two steps back. Look at it from this angle. Before two to three years did we have all these awesome java script frameworks that we now have? No. So people adapted their own frameworks that fit their needs which runs perfectly fine and has being running fine for quite a few years. Now when you fall into a project like that, you will probably think why would i ever want to learn all these boring old things since i know the new stuff. Ok again take two steps back. Look at current frameworks. Dont just look at them, dive into the code and look. Do you see a slight similarity between that and the current code of what your company use?

See everything that is there currently is a development of what already existed. Learn what you might think as "old" technology because these are the foundation on what current frameworks are built upon. Just because they are old does not mean its useless.

A few interns joined our company recently. A very talented group i must say. One guy was seated next to me, so i was asking how everything was going for him so far. He says "everything is good but i sure wish that i did not have to understand other's code and just write my own code instead". He was on a maintenance project and was mostly involved in bug fixes and enhancements. What i told him was that you will in a majority of cases be reading other's code and some may be bad and others would be good quality code. But whats important here is that you get to learn what is meant by bad code and good code my looking at other's code. Just writing your own code will get you no where. 

There are many other cases i would like to share but i do not want to lengthen this post much :) .. Ill probably break it down into sub posts in the time to come. Ok moving on to my next point,

Respect
As new people who enter the field of IT learn to always respect your seniors. That does not mean that you have to shake your head and agree on everything that they say or tell you to do. But dont think less of them just because they might know the latest technology that is out there or has just come out. Remember this, as you mature in this field you see many technology come and go. Some stick around and others fail. Maybe you like a certain new framework or language that has just come out, but just because your senior engineers do not want to incorporate it into the project does not mean they do not know that specific technology, it means that they with their experience often can judge if a certain technology is mature enough to adhere and incorporate. 

I must say i was in a similar situation when i first started working. Fresh out of grad school i was excited about going to work and starting off with the cool technology i just learned. But alas non of the tech leads or senior engineers even want to know about a particular technology i was talking about. I was left with some mix emotions. Sad, frustrated, angry and many more. Now when i look back i can see that those guys were actually right on the money. Because those technology i was talking about actually never materialized and some of them were a failure.

Remember to always respect your seniors no matter what. Some of them might be wrong sometimes. But most of the time they are right. Learn from them. If they think something you say is not correct dont be silent and in your mind mark that senior person as an idiot or incompetent. Ask him/her why that is so and the reason behind it. You will get a rationale answer i guarantee. You might not understand it fully at that moment, but some day you will.

 


Triumph
Ok last point. For anyone who got to this point thank you for reading this post and bare with me,just few more lines to go :) ... Actually this is an ongoing thing and you cant just accomplish this and wash your hands clean. To excel in this industry i believe the points i highlighted above are very important. Always keep learning, and i do not mean just about IT. Read anything that interests you. My father always says reading is the best habit you can have. Dont just be a nerd on a PC 24x7. Enjoy life, go out, play some sport you love, spend some time with family and loved ones. These i believe are all important things that make the essence of life just beautiful and more meaningful.


Ok thats about it guys. I know the last part is a bit too profound but just wanted to get that in there too :) . Cheers guys.....

Wednesday, February 9, 2011

The problem i faced with jqGrid and IE

Ok first of all before i start let me say this was not a problem with jqGrid or IE. I just started using jqGrid (hats off to the development team for the comprehensive documentation) in one of my projects i do in my free time. All was going well and i tested it out in IE7/8,FF2/3 and chrome. But i made a common mistake of not testing it in IE 6. When i went to deploy this at the clients environment alas it was IE 6. And the page i was using the jqGrid loaded and showed the message

Internet Explorer cannot open the Internet site http://<web site="">.com. Operation aborted.

I was baffled as to what this was. Debugging code at the client's environment was a pain. So as a work around i installed firefox for the moment until i found out what the issue was.

Went home, fired up note pad ++ and google of course :) .. in one site it mentioned that this could be the cause of a child element trying to modify a parent element. But i didnt find anything of such in my code.
In the path of an answer i saw that IE 8 was also giving the same error message but as a warning which didnt catch my eye. so i checked what that error was. it was as such;


Yikes now why didnt i see that first before my visit to the client. Oh well. So looking at the code, note that this was the only page that gave the problem and it was the only place where jqGrid was used. Looking at the DOM again i caught up with a code snippet of mine as such;


<div style="padding:10px 0 0 30px;">
    <table id="list2"></table> 
    <div id="pager2"/>
</div>

I saw the pager2 div didnt have a </div> element as i have just closed it within the same element it was defined. So hence i changed the following code as such;

<div style="padding:10px 0 0 30px;">
   <table id="list2"></table> <div id="pager2"></div>
   </div>
WAM!!! the bug dissapeared. So it seems that every div should be closed with a separate close div element rather than within the same opening tag although it doesnt have any content.

Now im not sure why that is. I Googled about it but didnt find any results as to why that happens. Maybe if you guys know the answer please do leave by a comment which would be highly appreciated.

Hope this helps any other person who would face a similar situation.

Cheers and happy coding to all !!!!!