User: pkendall
  Date: 01/07/30 02:23:14

  Modified:    src/main/org/jbossmq SpyMessageConsumer.java
  Log:
  make receive return a message from the server if it can in all modes.
  
  Revision  Changes    Path
  1.10      +37 -29    jbossmq/src/main/org/jbossmq/SpyMessageConsumer.java
  
  Index: SpyMessageConsumer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jbossmq/SpyMessageConsumer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SpyMessageConsumer.java   2001/07/29 22:54:43     1.9
  +++ SpyMessageConsumer.java   2001/07/30 09:23:14     1.10
  @@ -26,7 +26,7 @@
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    *   @author Hiram Chirino ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.9 $
  + *   @version $Revision: 1.10 $
    */
   public class SpyMessageConsumer implements MessageConsumer, SpyConsumer {
   
  @@ -82,14 +82,24 @@
   
                if (closed)
                        throw new IllegalStateException("The MessageConsumer is 
closed");
  +
                if (messageListener != null)
                        throw new JMSException("A message listener is already 
registered");
   
  -             subscription.receiving = true;
  +             if (session.modeStop)
  +                     return null;
   
  -             if ( subscription.actsLikeAQueue ) 
  -                     session.connection.receive(subscription, 0);
  +             if ( subscription.actsLikeAQueue ) {
  +                     SpyMessage msg = session.connection.receive(subscription, 0);
  +                     if( msg != null ) {
  +                             Message mes = preProcessMessage( msg );
  +                             if( mes != null )
  +                                     return mes;
  +                     }
  +             }
   
  +             subscription.receiving = true;
  +
                synchronized (messages) {
   
                        try {
  @@ -118,20 +128,30 @@
        }
   
        public Message receive(long timeOut) throws JMSException {
  +             if (timeOut == 0)
  +                     return receive();
  +
                if (closed)
                        throw new IllegalStateException("The MessageConsumer is 
closed");
  +
                if (messageListener != null)
                        throw new JMSException("A message listener is already 
registered");
   
  -             if (timeOut == 0)
  -                     return receive();
  +             if (session.modeStop)
  +                     return null;
   
                long endTime = System.currentTimeMillis() + timeOut;
   
  -             subscription.receiving = true;
  +             if ( subscription.actsLikeAQueue ) {
  +                     SpyMessage msg = session.connection.receive(subscription, 
timeOut);
  +                     if( msg != null ) {
  +                             Message mes = preProcessMessage( msg );
  +                             if( mes != null )
  +                                     return mes;
  +                     }
  +             }
   
  -             if ( subscription.actsLikeAQueue ) 
  -                     session.connection.receive(subscription, timeOut);
  +             subscription.receiving = true;
   
                synchronized (messages) {
   
  @@ -173,31 +193,19 @@
        public Message receiveNoWait() throws JMSException {
                if (closed)
                        throw new IllegalStateException("The MessageConsumer is 
closed");
  +
                if (messageListener != null)
                        throw new JMSException("A message listener is already 
registered");
   
  -             subscription.receiving = true;
  -             try {
  -
  -                     if ( subscription.actsLikeAQueue ) {
  -                             if (session.modeStop)
  -                                     return null;
  -
  -                             SpyMessage msg = 
session.connection.receive(getSubscription(), -1);
  -                             return preProcessMessage( msg );
  -                     }
  +             if (session.modeStop)
  +                     return null;
   
  -                     synchronized (messages) {
  -                             while (true) {
  -                                     if (session.modeStop)
  -                                             return null;
  -                                     return getMessage();
  -                             }
  -                     }
  -
  -             } finally {
  -                     subscription.receiving = false;
  +             if ( subscription.actsLikeAQueue ) {
  +                     SpyMessage msg = session.connection.receive(subscription, -1);
  +                     return preProcessMessage( msg );
                }
  +
  +             return getMessage();
        }
   
        public void close() throws JMSException {
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to