| Sergey Mikhanov | |
On re-entrant SBBs safety (August 12, 2008)I was always wondering what does “re-entrant” property of SBB mean. SLEE specification warns developer about potential problems related to multithreading (section 6.11):
When one of our SBBs required the loopback call to be possible, I have investigated the different possibilities for the potential error here.
It all boils down to the possibility for SBB to hold some custom state (for stateless objects re-entrant invocations from multiple threads are safe) and to the concurrency
control of the event delivery. In our case the dependencies between two SBBs could be depicted as below. Note that I am using
The actual details of the local method invocations (probably involving proxies) at steps 12 and 13 are omitted. Two questions arise here:
The answer for the first question is “we don’t actually care”. Section 2.2.7 of the SLEE specification says that “the SLEE may assign zero or more SBB objects to represent an SBB entity”, but 6.5.1 prohibits using of class fields for storing local object state. This means that even if the invocation 13 is delivered to another SBB object (and here we are coming to the answer for the second question), then its state would be the same. But this is not all. A more complicated situation may occur if:
In accordance with section 8.6.6, SLEE guarantees that invocations of any methods on the same SBB object are always serial (i.e. are never overlapping). Therefore, event handler will finish its work before step 13, thus (potentially) changing SBB entity state. We could conclude the simple rules for re-entrant SBBs:
I was unable to find any other possible problems with re-entrant SBBs, but readers from jNetX and OpenCloud (I know, there are some) are always welcome to prove me wrong. |
|
| © 2007–2025 Sergey Mikhanov | |