Using Postgres JSON

The applications of today are trying to persist data that has no fixed definition to it like user actions, application responses etc. Since the data is varied in nature the developers pick the Nosql paradigm to keep track of it.Often applications are spring based and spring has awesome support for Mongodb so developers start using Mongo db. Thus now there are multiple databases in the same application and there are overheads of working with the them. The admins have to keep track to two sets, the devs have to keep track to different pojos to make references etc. But do we really need to go down this road ?  I am ardent follower of  Postgres, so if we are using Postgres as the application store I will advise against going this road. Continue reading →

Junit Recepies : Having common Setup and Teardown

The other day I was refactoring one of our apis. We were removing some of the columns as they were not required. I believe in this exercise dropping the column was the most easy part. After that I removed the corresponding fields from the associated ORM and it was fine for the business related code.  But !! the big one, was my code was not compilable, as the object was being used in a lot of tests and thus my project was all painted RED.

While I was fixing all the required tests I realized most of the tests were on similar lines. We were pushing some data in tests, creating some required resources and then destroying them after the tests were done. Now we have blatantly copied the stuff in every testcase  with total disregard to the DRY principle. Continue reading →

Spring Recepies : URI redirection

We have a application which has gone through a short developments sprints. Things got added and then some got modified or removed etc. During this phase a number of service URLs got added/removed/modified. Now if such an application is getting crawled by Google, the you have a mess to clear about. Clearing such a mess is not easy, some URLs should give 301 to a relevant page which some should show 404 and 500 status errors. More over there can be other requirements from the application like domain/sub-domain redirections eg making http://www.myapp.com to myapp.com, ver1.myapp.com to ver2.myapp.com etc. Continue reading →

Tip ! : How to call static method from JSP

Every application has some user information which it displayed to the logged-in user. My application also has the same information, but at few places it needs to be converted to JSON format as well, besides being displayed. Now either I can pass this JSON information from my Controller or I can somehow reuse the existing information that is being  passed. I choose the second route, but then the next question comes to your mind is how to convert this  on server-side ? on client side etc. ? Since we already had a static method to do  such conversions so I needed to figure out a way how I can call the same static method which could do the conversion on JSP  ?

Answer : Spring EL, is the way to do this. Using this you can access any static method of a class or an Enum on the JSP.


<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>

<s:eval expression="T(com.rahul.devlearnings.MyClass).callStaticMethod()" var="data1" />

<s:eval expression="T(com.rahul.devlearnings.MyEnum).enum.call(data)" var="data2" />

Mongo, the silent killer!!

I was pretty much convinced that Mongo db is not the best choice for an application.  But a recent incident makes me believe that it is a silent killerof the application. As you work with it and  increase the amount of data/ concurrency  you realize  its one or more pain points.

Our application was working fine,  and one fine day one of the bugs got reported signup is not working as expected. It was creating user but could not login them. The app was not updated from quite some time, no changes to the schema how could this happen. So then we searched for logs, and it was sparkling clean !!! But still no user creation and other db operations, for some reason. After some debugging we realized that saves are getting called but data is not available in mongo after the operations and surprisingly it does not throw errors. WTF !!!
Continue reading →

Follow

Get every new post delivered to your Inbox.