Teja Saab wrote:I am trying to create the architecture for a system that has an inventory system as one of its components. Assuming that the inventory system contains inventory levels for products manufactured by different companies, I am trying to find the best way to keep the inventory system up to date with the different manufacturer inventory levels. Each one of the manufacturer's systems supports a JMS interface.
The inventory data in the inventory system is used in a B2C site. So response time is important. Sending a JMS message to a manufacturer in real time to find out available inventory while a customer is waiting for the web page to update is not an option.
I am thinking of an inventory synchronization approach with two MDBs. The first MDB registers itself with the EJB container's timer service.
The timer can be set to fire every few seconds or minutes. When the timer is fired, the timer callback method in the MDB will send a request message to each one of the manufacturers incoming queues. The manufacturer will reply back with the availability to the replyTo queue. The second MDB configured to listen on the replyTo queue will process the incoming message and update the inventory system. The B2C site always interacts with the local InventoryManager class which will in turn talk to the local inventory management system. In other words, the InventoryManager class decouples the external manufacturer interfaces from the rest of the application thereby promoting loose coupling.
What do you folks think about this approach?
Thanks for your inputs and critiques.
Teja Saab wrote:Thank you Suresh, Shyam and Maverick for your valuable inputs. You are right Maverick that I cannot assume that the partner's implementation uses the replyTo queue to send responses.
I thought about the publish/subscribe approach. However, one of the issues that I am trying to figure out is how to avoid the inventory data from being stale. Let me explain.
(1). Each one of the manufacturers probably have several different partner B2C sites that sell their stuff. Also assuming that the manufacturers publish their inventory data using a publish/subscribe mechanism to all partners, it is just a matter of time before my inventory data becomes stale.
For example, Manufacturer 1 publishes inventory 500 for product p1 to 10 different web sites including the one that I am architecting. I update my system with inventory 500 for product p1. However, another B2C site probably makes a sale of 200 items before me and that reduces the manufacturer's inventory to 300 now. However, my inventory is still showing as 500 (assuming that the next publish is yet to come from the manufacturer). If I make a sale for 400 items, I won't be able to fulfill the order since the available quantity is only 300.