Background
I, Nitol and Paul are 3 developers who worked at the early times of our career as java developers in a project named SPRINTRE in Bangladesh almost 6 years back. Coincidentally, we all 3 are now in USA. I and Nitol in California and are now neighbours and Paul just came to USA few weeks back and interviewing for openings in New York area. This is a part of a technical discussion going amongst us in JMS that Nitol sent. I am keeping it here finding valuable for reference.
Excerpt From Nitol’s Email
JMS is not mandatory thing, it’s a tool. If it properly used, then it can be useful. It helps to modularize code, improves maintainability …
Scenario
I’m going to describe one scenario from project Spintre, you remember right :). When a Purchase Order is approved, it should be saved in the PO table also it should save one record in accounts in proper cost center. How did we implemented it, we had accounts service call in PO module. Means we made PO module dependent on accounts module. Suppose we had a ActivityTracking module, which saves all user activity. How did we implemented it? We would have implemented it by calling activity tracking service. Suppose we have to include notification service also, when ever a PO is approved, purchase officer wants a email in his email box.
Without using JMS
accountService.save(amount, costcenter);
activityTrackingService(userObj, PoModuleIdentifier, ActivityApprove ..);
{
look for who want’s notification, get the email address and send the email.
}
How do you like this code implementation? How is the impression of a User who just clicked on the Approve button and waiting for so many thing to happen.
Those all service can be asynchronous, those activity don’t need to be real time. Now how we can use JMS here
when PO is saved, code block using JMS is
With JMS
{
Event event = new Event(po number, date, Module, ActivityType, user ……)
jmsPublisher.publish(event);
}
Done, clean implementation. But now we can write sevaral Subscriber
AccountModuleSubscriber {
receive(Message obj) {
Event event = (Event) obj;
// save it to correct cost center
}
}
ActivityTracker {
receive(Message obj) {
Event event = (Event) obj;
// save it log table
}
}
So, by using JMS you basically improved the application performance, It’s using idle time .. Jms broker will manage these different thread ..
2. I user ActiveMQ. I heard it became a apache project now.
Commercial Weblogic JMS is expensive. Basically all the EJB server has JMS support, Jboss, webspheare ….
3. JMS is a technology, a messaging architechture. It is scalable, if it is used properly. Means if design is good, then it’s scalable .. if design is bad, no meaning of using JMS.
4. You yourself can implement by using thread. But why to re-invent the wheel. JMS gives support of message persistent, redelivery, durability, thread pool .. so many support. Why not use those.
You can also make code moduler by using Observable-Observer pattern, but that is synchronous. You can use thread then, you’ve to maintain them ..
5. JMS is nice technology. Messaging technology is old, java implemented that near 2000. There are big server’s available for messging/message broker from long time back, like IBM MQSeries. Microsoft has there MS MQ implementation into windows may from 10-15 years ago. It’s a proven technology.
My informations can be wrong, anyway I hope it will help.
Оценка 5, базару ноль
LikeLike
This is very useful information. JMS sure as heck beats threads and polling!
LikeLike