User: norbert 
  Date: 00/06/04 20:19:25

  Modified:    src/java/org/spydermq/distributed/server
                        ConnectionReceiverRMIImpl.java
  Log:
  Add synchronization
  Local optimization
  
  Revision  Changes    Path
  1.6       +28 -24    
spyderMQ/src/java/org/spydermq/distributed/server/ConnectionReceiverRMIImpl.java
  
  Index: ConnectionReceiverRMIImpl.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/spyderMQ/src/java/org/spydermq/distributed/server/ConnectionReceiverRMIImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConnectionReceiverRMIImpl.java    2000/06/01 20:11:49     1.5
  +++ ConnectionReceiverRMIImpl.java    2000/06/05 03:19:24     1.6
  @@ -29,7 +29,7 @@
    *      
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.5 $
  + *   @version $Revision: 1.6 $
    */
   public class ConnectionReceiverRMIImpl extends UnicastRemoteObject implements 
ConnectionReceiverRMI
   {
  @@ -94,38 +94,42 @@
                                try {
                        
                                        //Find one session waiting for this Queue
  -                                     if (connection.modeStop) throw new 
NoReceiverException("This connection is stopped !");
  +                                     if (connection.modeStop) throw new 
Exception("This connection is stopped !");
                                        ConnectionQueue 
connectionQueue=(ConnectionQueue)connection.destinations.get(dest);
  -                                     if (connectionQueue==null) throw new 
NoReceiverException("There is no connectionQueue for this destination !");
  -                                     if (connectionQueue.NumListeningSessions==0) 
throw new NoReceiverException("There are no listening sessions for this destination 
!");
  +                                     if (connectionQueue==null) throw new 
Exception("There is no connectionQueue for this destination !");
  +                                     
  +                                     synchronized (connectionQueue) {
  +                                             
  +                                             //Find a SessionQueue
  +                                             if 
(connectionQueue.NumListeningSessions==0) throw new Exception("There are no listening 
sessions for this destination !");
                        
  -                                     Iterator 
i=connectionQueue.subscribers.iterator();
  -                                     while (i.hasNext()) {
  -                                             SpySession 
session=(SpySession)i.next();
  -                                             
sq=(SessionQueue)session.destinations.get(dest);
  -                                             if (sq.NumListeningSubscribers!=0) 
break;
  -                                     }
  -                                     if (sq==null||sq.NumListeningSubscribers==0) {
  -                                             Log.error("FIXME: The listeners count 
was invalid !");
  -                                             throw new NoReceiverException("There 
are no listening sessions for this destination !");
  +                                             Iterator 
i=connectionQueue.subscribers.iterator();
  +                                             while (i.hasNext()) {
  +                                                     SpySession 
session=(SpySession)i.next();
  +                                                     
sq=(SessionQueue)session.destinations.get(dest);
  +                                                     if 
(sq.NumListeningSubscribers!=0) break;
  +                                             }
  +                                             if 
(sq==null||sq.NumListeningSubscribers==0) {
  +                                                     Log.error("FIXME: The 
listeners count was invalid !");
  +                                                     throw new Exception("There are 
no listening sessions for this destination !");
  +                                             }
  +                                     
  +                                             //Try with this sessionQueue
  +                                             sq.dispatchMessage(dest,mes);
  +                             
  +                                             //Our work is done here
  +                                             break;
                                        }
   
  +                             } catch (NoReceiverException e) {
  +                                     //This SessionQueue should not have been 
registered !
  +                                     continue;
                                } catch (Exception e) {
                                        //This error is non-recoverable : we must 
unregister from this queue
  +                                     //Let the JMSServerQueue do its work
                                        Log.log(e);
                                        throw new NoReceiverException("There are no 
listening sessions in this connection");
  -                             } 
  -
  -                             try {
  -                                     sq.dispatchMessage(dest,mes);
  -                             } catch (NoReceiverException e) {
  -                                     //Unregister this session !
  -                                     
  -                                     continue;
                                }
  -                             
  -                             break;
  -                             
                        }
                        
                }
  
  
  

Reply via email to