6 Replies Latest reply on Nov 7, 2006 5:33 AM by ci

    Nested conversation question

    Newbie

      Hi!

      I tried to use nested conversation. I took an Issue example and made my CRUD after it. I have a set of Clients, every Client has a set of Addresses. I wanted to organize a CRUD around a selected Client and a nested CRUD around a selected Address.

      But there are situations where this approach fails. When a nested conversation is created (inside a parent one) and destroyed after the request is accomplished, there are an unlocked nested conversation and locked parent one, and the latter is locked by the thread of the last request, say http-0.0.0.0-8080-11.

      Then everything is perfect until I do @End of the nested conversation. A different thread is on the stage, say http-0.0.0.0-8080-8. It destroys the nested conversation, but cannot unlock the parent, so it stays locked to http-0.0.0.0-8080-11 (normal case, ReentrantLock does everything correctly)

      Now any request in any thread different from http-0.0.0.0-8080-11 will fail to restore the parent conversation, because Manager.java:536 cannot perform ce.lock(). So, I have a "No stored conversation, or concurrent call to the stored conversation" message, which breaks my understanding how it should work.

      I have several workstation to test this behaviour. Of course, if tomcat creates few threads, say 3, I can miss the error for rather long time. But if there are 100 threads under tomcat, it fails immediately.

      Seam is from cvs (today), JBoss 4.0.5.GA.


      Please clarify what is wrong with my idea of nested conversations...

      (By the way, Issues example works exactly the same way, falling down when I try to view a comment which is just created.)


      I consider getting rid of them at all, but it seems to be very elegant approach - I'd better use it instead of any workarounds...

      Thank you in advance.

        • 1. Re: Nested conversation question
          Newbie

          And by the way, are concurrent nested conversations inside one parent conversation possible?

          • 2. Re: Nested conversation question
            Gavin King Master

            This would be a bug in Seam's new concurrency stuff. thanks for discovering that. I'll fix it today.

            http://jira.jboss.com/jira/browse/JBSEAM-454

            Yes, concurrent nested conversations are supposed to be possible :)

            • 3. Re: Nested conversation question
              Gavin King Master

              This should now be fixed in CVS. Please test it out.

              By the way, it depends what you mean by "concurrent". My fix enforces that a singe root conversation can have only one thread at a time. However, a single root conversation can still have many nested conversations (usually I call them "concurrent", but I don't mean thread-level concurrency).

              • 4. Re: Nested conversation question
                Newbie

                Sorry, it does not work either.

                In Manager class there is an unlockConversation() method. After the nested conversation is destroyed, getCurrentConversationEntry() will return null, and its stack (which is obviously not empty) won't be unlocked.

                I suppose something like that:

                public void unlockConversation()
                 {
                 ConversationEntry ce = getCurrentConversationEntry();
                 if (ce!=null)
                 {
                 ce.unlock();
                 }
                 else
                 {
                 // current can be destroyed, but its stack can be not even unlocked
                 for ( String conversationId: currentConversationIdStack )
                 {
                 if (conversationId.equals(currentConversationId)) continue; // destroyed
                 ConversationEntry cen =
                 ConversationEntries.instance().getConversationEntry(conversationId);
                 if (cen != null)
                 {
                 cen.unlock();
                 break;
                 }
                 }
                 }
                 }


                It works :) After you did the whole stack to share one lock instance, the problem is nearly solved.

                Btw, thank you for Seam :)


                • 5. Re: Nested conversation question
                  Gavin King Master

                  Yep, good work mate, I used:

                  public void unlockConversation()
                   {
                   ConversationEntry ce = getCurrentConversationEntry();
                   if (ce!=null)
                   {
                   ce.unlock();
                   }
                   else if ( isNestedConversation() )
                   {
                   ConversationEntries.instance().getConversationEntry( getParentConversationId() ).unlock();
                   }
                   }


                  • 6. Re: Nested conversation question
                    Newbie

                    It seems to work! Great! Thanks Gavin :)