I’m not sure if we are doing something wrong, but we are experiencing odd 
behavior related to DataObjects that exist in multiple contexts.

In our application we use a single ServerRuntime, and each user that connects 
(via handheld scanner) gets their own context ( serverRuntime.newContext() )

It is my understanding that if more than one ObjectContext has the same 
DataObject, when changes to that object are committed, the other context that 
has that same object will automatically be updated with the changes. But this 
does not seem to be happening for me.

The specific scenario, is that I have two different people receiving product to 
the same PurchaseOrderLine. If they both bring in that PurchaseOrderLine before 
anything has been received, the “receivedQuantity” on that POL starts out at 0 
(ZERO). When person A scans a box, the POL.receivedQuantity increments to 1, 
and then increments to 2 when he scans another. Then if person B scans a box, 
their POL still thinks the “receivedQuantity” is ZERO and it increments it to 
1. So what I have in the database is a POL with receivedQuantity 1, but there 
are actually InventoryTransactions showing that it should be at 3.

Not sure if this is related but we often see in the log during a commit -> 
"snapshot version changed, don't know what to do…”

I doubt this is normal behavior and figure its indicating we are doing 
something wrong, but I’m not sure what.

Has anyone else experienced anything like this or have any suggestions for me.

I read the Cayenne docs here 
(https://cayenne.apache.org/docs/4.0/cayenne-guide/performance-tuning.html#turning-off-synchronization-of-objectcontexts
 
<https://cayenne.apache.org/docs/4.0/cayenne-guide/performance-tuning.html#turning-off-synchronization-of-objectcontexts>)
 that it does not recommend using synchronization for a large number of users 
(peer Contexts), however I tested this with only 2 and still experience the 
issue.  And now that I have just reread that documentation, I may have 
misunderstood that the object is automatically updated, and that instead the 
Context is notified of the changes via an event, but if I am not listening that 
event (& handling), then that could be why the other Context does not have the 
updated information on that object.

Thanks,
Matt

Reply via email to