File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes [JMS] Condition treatment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "[JMS] Condition treatment " Watch "[JMS] Condition treatment " New topic

[JMS] Condition treatment

j man

Joined: Jul 06, 2012
Posts: 4
Sorry, my english isn't good

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)?

Devendra Borkar

Joined: Feb 15, 2012
Posts: 1
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 ?
j man

Joined: Jul 06, 2012
Posts: 4
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
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.
j man

Joined: Jul 06, 2012
Posts: 4
-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

the need looked like this: Article
I agree. Here's the link:
subject: [JMS] Condition treatment
jQuery in Action, 3rd edition