I have a database of items and an external application has what I can connect via JMS to recover the price (I send the itemID to the application I return the current price of item) knowing that the price changes in real time.
Now I want to start treatment on an item, but only when its price becomes equal to a fixed price (for example 50 $).
I note that I can have several items to be processed simultaneously
I thought a solution: infinite loop
This solution seems to me quite heavy, How can I take advantage of the JMS API to provide a more optimal solution (using Publish / Subscribe for example)?
Hi J Man,
Any specific reason for using JMS here? You can connect to the database directly and can fetch required data.
Also can you elaborate the meaning of recovering the price of item ?
Joined: Jul 06, 2012
thank you Devendra Borkar for your reply
The database items: is local. (Yes direct connection via jdbc),
But the application providing the prices of Items is an external application (I send itemId , and I get the current price)
so I have use a method to connect to this external application (RMI, JMS, WS, Corba, HTTP ...)
In my case: the only JMS can be used
Well, yes, that's a heavy solution, but I don't understand why you're asking about JMS. You're already using JMS.
So let's go back to the original problem, rather than discussing your proposed solution to the problem which really isn't a solution.
You're generating a thousand (or a million) requests per second to see when an item's price becomes equal to some value, and you think this is too much processing. And I would agree. But I know nothing about your data. How often do the prices change? Once a month? Once a day? Once a second? And when the item's price changes, how long can you wait until you act on that information? A week? A second? Without knowing your requirements it's hard to say how you should implement those requirements.
In general you might change from the solution where you continually ask the service for the price, to a solution where you ask the service to tell you when the price changes. You could still use JMS for that, but then your code would send a message to the service telling it what item it was interested in, and then wait for a message from the service which tells your code that the price changed.
Joined: Jul 06, 2012
-my items are: shares of the stock market.
-change prices are: Financial events (real time)
-The external application has a response time of 1 second
-My system must react once the prices change