Of course, every scenario demands different combination of components of software to be used. And the success formula is directly related on the way you design your final architecture.
In 2007 I was called to solve some bad issues one big retail company was having in their environment. Basically, they had one of the biggest consulting companies developing their solutions in a JEE environment, with lots of integrations. But some decisions they made on the design phase was causing lots of troubles, and giving a huge headache for the retailer's IT Manager.
Besides some basic issues they couldn't resolve, like adjusting the heap size for the application server, the major problems weren't that easy to address. That's delicate. You have to tell they spent money in a not well designed architecture, and that they will fail with that is not a straight task. So, I decided to have a different approach, showing how to fix the current scenario, but also recommending changes to support better performance in the future. And one of the points was related to the JMS.
The design for that project was using JMS to exchange data between one ERP and the developed java system responsible to populate other systems. That was the biggest bottleneck. The performance was critical, and it was failing on delivering some of the messages.
So, first thing to analyze was the amount of data transmitted in a daily basis. More than 40GB. Oh, looks bad... So, I picked up the biggest file. Around 10MB. Basically, if you work with persisted messages, the data segments within JMS have a predefined size, and a predefined amount of files that can or cannot rotate when they're full. These values can be changes, of course. But they left the default values there. So, when a 10MB message was about to be stored in the data segments within the JMS, with less then 10% of it's size, it was failing.
The final document presented the two scenarios. For the first one, "to make it work as it is", the recommendation was to set a huge data segment size. And the second one, was to make the JEE application responsible for the integration to act like a FTP Hub, being fed with JMS notifications:
- For the messages with less then certain amount of data, lets say 100K, the message would contain the real data, and the process would be the same;
- Bigger that that, it would make use of FTP to get the data and send it to the target system, database or file system.
Some other recommendations over the use of JMS were included on the final document, like making concurrent processes instead of having just one process running. But one of the issues they were having was related to the target JMS availability. In fact, they were thinking in the opposite way. The application that is about to send the messages was running in a application server. So, it should send to a JMS Queue within the same application server. So, if the target consumer is not available, you won't stop. In fact, the consumer is responsible to go to the source and get the messages. With this scenario, you won't have any trouble. It works perfectly!
I also created a PoC to show them what we was talking about, and how to implement it. When I arrived there, JMS was being questioned, and they were also considering to substitute it by web services, because it was failing. With that kind of architecture, Web Services would become the "big bad wolf" sooner or later. Anyways, when I finished my assignment, JMS was in a good picture again.
In summary, JMS is a really powerful tool. But you have to apply it with some premisses:
- Is the communication asynchronous?
- What kind of information is being loaded into the messages?
- Is it confidential information? Not a good idea to use it on queues!
- What is the amount of data, per message? Focus on the biggest messages;
- And the final question is: do you really need JMS? I mean, I saw one design where JMS was supposed to be used as a logger, for one standalone application. The responsible for that wasn't unable to answer this question with any good and reasonable arguments.
During the architecture design, we should try to come up with discussions related to the peaks on daily/monthly processing, and dependencies. You might need to consider these information on your final design, to further concurrency setup and strategy to adopt for the distributed transactions.
JMS can be a really nice addition to your projects, but the project should require it, and not the opposite.
JMS can be a really nice addition to your projects, but the project should require it, and not the opposite.