Hello All,
  Thanks very much for all the help you have provided for this query.
I looked into the Java pet store class which you had referred me to.
And have also implemented a facade class.

Here is an example of what our application looks like.

There is an MDB called MyMDB, a stateful session bean called 
MyStatefulSessionBean and a facade class called MyFacade

MyMDB.java
-----------
public class MyMDB extends java.lang.Object implements 
javax.ejb.MessageDrivenBean, javax.jms.MessageListener {
        static m_myFacade;

        private _createFacade()
        {
                // Creates Facade class
                // Initializes myStatefulSessionBean variable in the Facade class
        }

        public void onMessage(javax.jms.Message message)
        {
                if( message is init_message )
                {
                        _createFacade();
                }
                m_myFacade.processMessage( message );
        }
}

MyStatefulSessionBean.java
---------------------------
public class MyStatefulSessionBean extends java.lang.Object implements 
javax.ejb.SessionBean
{
        public void processMessage( Message message );
}

MyFacade.java
-------------
public class MyFacade extends Object
{
        MyStatefulSessionBean m_myStatefulSessionBean;

        public synchronized void processMessage( Message message )
        {
                myStatefulSessionBean.processMessage();
        }
}

But when the application runs, and sends an init message to MyQueue ( with 
which the MDB is accociated ), the onMessage() of MDB gets called. And the 
processMessage() gets called and facade class is initialized. The system 
behaves in the way it is expected to.

Then, if MyQueue recieves another message, the system still beahves fine by 
calling processMessage().

The problem occurs if MyQueue gets more than one messages ( from more than 
one threads ). The control comes into onMessage() everytime. Unfortunately, 
m_myFacade.processMessage( message ) doesn't get in all the cases. I don't 
know if this is a problem with synchronization or may be I am doing 
something wrong here. Please somebody help.

Thanks,
Vani






>From: "The elephantwalker" <[EMAIL PROTECTED]>
>Reply-To: Orion-Interest <[EMAIL PROTECTED]>
>To: Orion-Interest <[EMAIL PROTECTED]>
>Subject: RE: Concurrent calls to Session bean methods
>Date: Thu, 21 Mar 2002 21:37:55 -0800
>
>The sfsb has a _session_ which is bound to the client. So the client could
>be anywhere, irregardless of a cluster.
>
>oc4j has a last method state replication which makes sure that all sfsb's
>have the same _session_.
>
>A slsb wouldn't care, and doesn't have the same problem with concurrency,
>since they are not reentrant.
>
>regards,
>
>the elephantwalker
>
>
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED]]On Behalf Of Romen Law
>Sent: Thursday, March 21, 2002 2:33 PM
>To: Orion-Interest
>Subject: Re: Concurrent calls to Session bean methods
>
>
>ello,
>
>What if the application is deployed in a cluster (even the web tier)? Would
>that nullify the synchronised effect?
>
>cheers
>romen
>
>----- Original Message -----
>From: "The elephantwalker" <[EMAIL PROTECTED]>
>To: "Orion-Interest" <[EMAIL PROTECTED]>
>Sent: Thursday, March 21, 2002 3:47 PM
>Subject: RE: Concurrent calls to Session bean methods
>
>
> > John,
> >
> > Here is the offending class, compliments of the Sun Blueprint team:
> >
> > public class ShoppingClientControllerWebImpl implements
>WebClientController
> > {
> >
> >     private ShoppingClientControllerLocal sccEjb;
> >     private HttpSession session;
> >
> >     public ShoppingClientControllerWebImpl() {
> >     }
> >
> > //   ... stuff...
> > //
> >
> > // the important bit ...
> >
> >     public synchronized EventResponse handleEvent(Event ev)
> >         throws EventException {
> >             return sccEjb.processEvent(ev);
> >     }
> >
> > }
> >
> > So you see that the webcontroller is the _only_ access to the sfsb. And
>the
> > only call is synchronized, thus preventing cocurrent calls to the 
>stateful
> > session bean.
> >
> > regards,
> >
> > the elephantwalker
> > www.elephantwalker.com
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of
> > [EMAIL PROTECTED]
> > Sent: Wednesday, March 20, 2002 12:05 PM
> > To: Orion-Interest
> > Subject: RE: Concurrent calls to Session bean methods
> >
> >
> >
> > I haven't seen the history on this issue, but it interests me.  I had a
> > quick look at the ShoppingClientControllerEJB class that is given as an
> > example by Sun in the Session Facade design pattern, but couldn't see
>where
> > they are synchronizing calls.  Can you provide some more clues?
> >
> > Thanks,
> >
> > John H.
> >
> >
> >
> >                     "The elephantwalker"
> >                     <[EMAIL PROTECTED]>       To:
> > [EMAIL PROTECTED]
> >                     Sent by:                         cc:
> >                     owner-orion-interest@orion       Subject:     RE:
> > Concurrent calls to Session bean methods
> >                     server.com
> >
> >
> >                     03/19/02 10:31 PM
> >                     Please respond to
> >                     Orion-Interest
> >
> >
> >
> >
> >
> >
> > Vani,
> >
> > You can use the petstore trick. Use a facade class which sychronizes 
>each
> > call to your session bean. That should do the trick.
> >
> > This is a _famous_ problem with session beans.
> >
> > regards,
> >
> > the elephantwalker
> > www.elephantwalker.com
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Vani H.S.
> > Sent: Wednesday, March 20, 2002 12:04 AM
> > To: Orion-Interest
> > Subject: Concurrent calls to Session bean methods
> >
> >
> > Hello All,
> >
> >   I have been trying to deploy an application consisting of session 
>beans
> > and mdbs onto orion1.5.4.
> >   But I seem to run into deadlocks, because my session bean gets called
> > concurrently. Please can anybody can tell me if there is a setting to
>allow
> > concurrent calls so that, when a session bean method is called at one
>time,
> > the EJB container blocks the concurrent method call and allows it to
> > proceed
> > when the previous call has completed?
> >   If not, how should this problem of concurrent calls be handled in 
>orion?
> >   Please help.
> > Thanks,
> > Vani
> >
> >
> >
> >
> >
> > The allow-concurrent-calls element specifies whether a stateful session
> > bean
> > instance allows concurrent method calls. By default,
> > allows-concurrent-calls
> > is false. However, when this value is set to true, the EJB container
>blocks
> > the concurrent method call and allows it to proceed when the previous 
>call
> > has completed.
> >
> >
> >
> >
> >
> > _________________________________________________________________
> > Join the world's largest e-mail service with MSN Hotmail.
> > http://www.hotmail.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
>




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


Reply via email to