JVM Boolean Options

Introduction While trying to generate a Java Heap Dump, I remembered there is one JVM option I could use for this purpose. Since I can’t always remember these options’ names, I went to the Oracle documentation. The problem So I could extract the following arguments: After limiting my Java Heap size to a value that I know it’s too low, I was expecting the Heap Dump to be generated whenever I got an OutOfMemoryError. But no dump got generated. I googled the issue, checked for JVM bugs but the only reported issue… Read More

Teaching is the best way to learn

Introduction Software development is all about knowledge, and nowadays the number of things a programmer needs to know skyrocketed. Most of the time developers are hired by matching their current skills with some project requirements. The project eventually ends, and the developer is assigned to a new project, sometimes using different technologies than what he was previously hired for. What’s the policy for training this guy to deliver his best the soonest possible? Usually, training and coaching are left-out, so each programmer is on his own. Every time we leave things to chance a huge… Read More

Why I never blame open source projects

Every now and then I get to read someone’s bad thought towards a given open-source framework. When I started programming Struts web framework was at its prime, everybody loved it. But then, little by little people started blaming it and then hate followed. Then people started blaming Hibernate and recently MongoDB. I’ve even read that “I shouldn’t use MongoDB“. Well, I delivered projects on Struts, Hibernate and MongoDB, and none of those was ever a blocker. If there is someone to blame it’s usually us, not the frameworks we use. If you… Read More

How to retry JPA transactions after an OptimisticLockException

This is the third part of the optimistic locking series, and I will discuss how we can implement the automatic retry mechanism when dealing with JPA repositories. You can find the introductory part here and the MongoDB implementation here. JPA requires running the Persistence Context code inside a Transaction, and if our Transaction Manager catches a RuntimeException, it initiates the rollback process. This makes the Persistence Context unusable since we should discard it along with the roll-backed Transaction. Therefore it’s safer to retry the business logic operation when we are not within… Read More

Optimistic locking retry with MongoDB

In my previous post I talked about the benefit of employing optimistic locking for MongoDB batch processors. As I wrote before, the optimistic locking exception is a recoverable one, as long as we fetch the latest Entity, we update and save it. Because we are using MongoDB we don’t have to worry about local or XA transactions. In a future post, I’ll demonstrate how you can build the same mechanism when using JPA. The Spring framework offers a very good AOP support and, therefore, it makes easy implementing an automatic retry mechanism,… Read More

New Video Course