Package org.jboss.jms.message

Examples of org.jboss.jms.message.MessageProxy


      }
   }
  
   private void handleMessageInternal(Object message) throws Exception
   {
      MessageProxy proxy = (MessageProxy) message;

      if (trace) { log.trace(this + " receiving message " + proxy + " from the remoting layer"); }

      synchronized (mainLock)
      {
         if (closed)
         {
            // This should never happen - we should always wait for all deliveries to arrive
            // when closing
            log.warn(this + " is closed, so ignoring message");
           
            return;
         }

         proxy.setSessionDelegate(sessionDelegate, isConnectionConsumer);

         //Add it to the buffer
         buffer.addLast(proxy, proxy.getJMSPriority());

         lastDeliveryId = proxy.getDeliveryId();
        
         if (trace) { log.trace(this + " added message(s) to the buffer"); }

         messageAdded();
View Full Code Here


            if (trace) { log.trace("InterruptedException, " + this + ".getMessage() returning null"); }
            return null;
         }
      }

      MessageProxy m = null;
            
      if (!closed && !buffer.isEmpty())
      {
         m = (MessageProxy)buffer.removeFirst();
      }
View Full Code Here

   {
      ClientDelivery del = (ClientDelivery)message;
     
      JBossMessage msg = (JBossMessage)del.getMessage();
     
      MessageProxy proxy = JBossMessage.
         createThinDelegate(del.getDeliveryId(), (JBossMessage)msg, del.getDeliveryCount());
     
      JBossDestination dest =(JBossDestination) proxy.getJMSDestination();
     
      // If the message received is a direct destination (MessageSucker), and this Consumer is not a MessageSucker.. then we need to replace the destination
      if (dest.isDirect() && !this.consumerDelegate.getDestination().isDirect())
      {
         proxy.setJMSDestination(msg.getOriginalSuckerDestination());
      }
     
      proxy.setSource(cbManager);

      //TODO - we temporarily need to execute on a different thread to avoid a deadlock situation in
      //       failover where a message is sent then the valve is locked, and the message send cause
      //       a message delivery back to the same client which tries to ack but can't get through
      //       the valve. This won't be necessary when we move to a non blocking transport
View Full Code Here

  
            List cancels = new ArrayList();
  
            for(Iterator i = buffer.iterator(); i.hasNext();)
            {
               MessageProxy mp = (MessageProxy)i.next();
              
               DefaultCancel cancel =
                  new DefaultCancel(mp.getDeliveryId(), mp.getDeliveryCount(), false, false);
              
               cancels.add(cancel);
            }
                 
            if (trace) { log.trace("Calling cancelDeliveries"); }
View Full Code Here

    *        or null if one is not immediately available. Returns null if the consumer is
    *        concurrently closed.
    */
   public MessageProxy receive(long timeout) throws JMSException
   {               
      MessageProxy m = null;     
     
      synchronized (mainLock)
      {       
         if (trace) { log.trace(this + " receiving, timeout = " + timeout); }
        
         if (closed)
         {
            // If consumer is closed or closing calling receive returns null
            if (trace) { log.trace(this + " closed, returning null"); }
            return null;
         }
        
         if (listener != null)
         {
            throw new JMSException("The consumer has a MessageListener set, " +
               "cannot call receive(..)");
         }
                      
         receiverThread = Thread.currentThread();
              
         long startTimestamp = System.currentTimeMillis();
                 
         try
         {
            while(true)
            {                            
               if (timeout == 0)
               {
                  if (trace) { log.trace(this + ": receive, no timeout"); }
                 
                  m = getMessage(0);                    
                 
                  if (m == null)
                  {
                     return null;
                  }
               }
               else if (timeout == -1)
               {
                  //ReceiveNoWait
                  if (trace) { log.trace(this + ": receive, noWait"); }
                 
                  m = getMessage(-1);                    
                 
                  if (m == null)
                  {
                     if (trace) { log.trace(this + ": no message available"); }
                     return null;
                  }
               }
               else
               {
                  if (trace) { log.trace(this + ": receive, timeout " + timeout + " ms, blocking poll on queue"); }
                 
                  m = getMessage(timeout);
                                   
                  if (m == null)
                  {
                     // timeout expired
                     if (trace) { log.trace(this + ": " + timeout + " ms timeout expired"); }
                    
                     return null;
                  }
               }
                             
               if (trace) { log.trace(this + " received " + m + " after being blocked on buffer"); }
                      
               boolean ignore =
                  checkExpiredOrReachedMaxdeliveries(m, sessionDelegate, maxDeliveries, shouldAck);
              
               if (!isConnectionConsumer && !ignore)
               {
                  final DeliveryInfo info = new DeliveryInfo(m, consumerID, queueName, null, shouldAck, m.getSource());
                 
                  if (timeout <= 0 || sessionDelegate.getTransacted())
                  {
                     ignore = ! sessionDelegate.preDeliver(info);

                     // If post deliver didn't succeed and acknowledgement mode is auto_ack
                     // That means the ref wasn't acked since it couldn't be found.
                     // In order to maintain at most once semantics we must therefore not return
                     // the message
                    
                     if (!ignore)
                     {
                        ignore = !sessionDelegate.postDeliver();
                     }
                  }
                  else
                  {
                     //JBMESSAGING-1850
                     Callable<Boolean> afterReceive = new Callable<Boolean>()
                     {
                        public Boolean call() throws Exception
                        {
                           if (! sessionDelegate.preDeliver(info))
                           {
                              return true;
                           }

                           // If post deliver didn't succeed and acknowledgement mode is auto_ack
                           // That means the ref wasn't acked since it couldn't be found.
                           // In order to maintain at most once semantics we must therefore not return
                           // the message

                           return !sessionDelegate.postDeliver();
                        }
                     };

                     java.util.concurrent.Future<Boolean> f = pool.submit(afterReceive);

                     long tmUsed = System.currentTimeMillis() - startTimestamp;
                    
                     long timeDelta = timeout - tmUsed;
                     long timeLeft = timeDelta <= minTimeoutProcessTime ? minTimeoutProcessTime : timeDelta ;
                    
                     if (trace)
                     {
                        log.trace("Time left: " + timeLeft + " timeout " + timeout + " tmUsed " + tmUsed);
                     }
                    
                     try
                     {
                        ignore = f.get(timeLeft, TimeUnit.MILLISECONDS);
                     }
                     catch (InterruptedException e)
                     {
                        log.warn("Interrupted during getting future result.", e);
                     }
                     catch (ExecutionException e)
                     {
                        log.warn("received application exception.", e.getCause());
                        Throwable t = e.getCause();
                        if (t instanceof JMSException)
                        {
                           throw (JMSException)t;
                        }
                     }
                     catch (TimeoutException e)
                     {
                        log.warn("Timed out waiting for post message processing " + m + " within time " + timeLeft);
                        ignore = false;
                        sessionDelegate.processMessageTimeout();
                     }
                  }

                  if (trace)
                  {
                     log.trace("Post deliver returned " + !ignore);
                  }

                  if (!ignore)
                  {
                     m.incDeliveryCount();
                  }
               }
                                            
               if (!ignore)
               {
View Full Code Here

            if (trace) { log.trace("InterruptedException, " + this + ".getMessage() returning null"); }
            return null;
         }
      }

      MessageProxy m = null;
            
      if (!closed && !buffer.isEmpty())
      {
         m = (MessageProxy)buffer.removeFirst();
        
View Full Code Here

    */
   private class ListenerRunner implements Runnable
   {
      public void run()
      {        
         MessageProxy mp = null;
        
         MessageListener theListener = null;
        
         synchronized (mainLock)
         {
View Full Code Here

     
      // Need to be redelivered in reverse order.
      for (int i = toRedeliver.size() - 1; i >= 0; i--)
      {
         DeliveryInfo info = (DeliveryInfo)toRedeliver.get(i);
         MessageProxy proxy = info.getMessageProxy();       
        
         ClientConsumer handler = state.getCallbackHandler(info.getConsumerId());
        
         if (handler == null)
         {
View Full Code Here

  
   public Object handleCreateMessage(Invocation invocation) throws Throwable
   {
      JBossMessage jbm = new JBossMessage(0);
      
      return new MessageProxy(jbm);
   }
View Full Code Here

     
      MethodInvocation mi = (MethodInvocation)invocation;
     
      // Load the session with a message to be processed during a subsequent call to run()

      MessageProxy m = (MessageProxy)mi.getArguments()[0];
      String theConsumerID = (String)mi.getArguments()[1];
      String queueName = (String)mi.getArguments()[2];
      int maxDeliveries = ((Integer)mi.getArguments()[3]).intValue();
      SessionDelegate connectionConsumerDelegate = ((SessionDelegate)mi.getArguments()[4]);
      boolean shouldAck = ((Boolean)mi.getArguments()[5]).booleanValue();
View Full Code Here

TOP

Related Classes of org.jboss.jms.message.MessageProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.