I'm getting some very strange behavior with BMP entity beans.
Background:
The trading system I'm writing uses JMS for communication. A user will register with the system by creating a temporary queue, and setting that queue as the reply-to queue in it's registration message. The server will receive this message, and create an entity bean for each registered user. Unfortunately, because queues are not serializable, we can't put it in the database (at least, we think that's why CMP's weren't working). So we have a BMP that is stored in memory. Since we'll have maybe 200 users, this wouldn't be a big problem.
Prior Behavior
It's been working fine in that when the user placed a trade, a message with the results of the trade would be sent back to the user on the queue with which he logged in.
New Behavior:
We need to send each user what is effectively a personalized summary status report every 30 seconds, as well as when he logs in. It is sent using the same queue.
When the user first logs in, we send this summary on the queue, no problem. Then we have a
thread which every 30 seconds, grabs all users from the DB, does some calc, and, for users who have registered, sends them the summary. For some reason, when I do the lookup on the
EJB, I can't find the user. Despite giving a valid username (which works in other cases), I get an anonymous instance of the entity bean. But I use the same lookup code in both cases!
Here is some of the code.
OrderUpdateQueueLookupTable is the entity bean (bad name, it was created when I was first learning about entity beans).
This is the method works, when a trade is executes
This method does not work
The method they rely on to do the lookup.
In the case where it doesn't work, the 3 field print statements in the 3rd method all have null values (anonymous instance), and so it apparently can't find the user. I've checked stupid things like making sure the username is correct, etc. They all seem to be in place.
Also confusing, the second method (sendEquityUpdate) does work in one case. When the user first registers, the entity bean gets created, and an equityUpdate gets sent (they happen within the same transcation, so maybe that has something to do with it). That does work. It just doesn't work when requested by the timer. I see the print statements, so I know the code is being called, it just things the user was never registered.
Two other notes. We only call remove when we first register (and then only if the user was already registered--basically, if you are already logged in on one computer, and log in on a second, the second overwrites the info about you being on the first computer). We also cache the beans: Entity Cache, cache between transactions = true, exclusive strategy.
Any ideas? This is baffling me.
--Mark
[Broke up overlong line for readability - Jim]
[ March 11, 2003: Message edited by: Jim Yingst ]