Package org.jboss.jms.client.state

Examples of org.jboss.jms.client.state.ConsumerState


      // Create the message handler
      SessionState sessionState =
         (SessionState)((DelegateSupport)invocation.getTargetObject()).getState();
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();
      SessionDelegate sessionDelegate = (SessionDelegate)invocation.getTargetObject();
      ConsumerState consumerState = (ConsumerState)((DelegateSupport)consumerDelegate).getState();
      int consumerID = consumerState.getConsumerID();
      int prefetchSize = consumerState.getBufferSize();
      QueuedExecutor sessionExecutor = sessionState.getExecutor();
      int maxDeliveries = consumerState.getMaxDeliveries();
     
      //We need the queue name for recovering any deliveries after failover
      String queueName = null;
      if (consumerState.getSubscriptionName() != null)
      {
         queueName = MessageQueueNameHelper.
            createSubscriptionName(connectionState.getClientID(),
                                   consumerState.getSubscriptionName());
      }
      else if (consumerState.getDestination().isQueue())
      {
         queueName = consumerState.getDestination().getName();
      }
     
      MessageCallbackHandler messageHandler =
         new MessageCallbackHandler(isCC, sessionState.getAcknowledgeMode(),
                                    sessionDelegate, consumerDelegate, consumerID, queueName,
                                    prefetchSize, sessionExecutor, maxDeliveries);
     
      sessionState.addCallbackHandler(messageHandler);
     
      CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
      cm.registerHandler(consumerID, messageHandler);
        
      consumerState.setMessageCallbackHandler(messageHandler);
     
      //Now we have finished creating the client consumer, we can tell the SCD
      //we are ready
      consumerDelegate.changeRate(1);
View Full Code Here


      return consumerDelegate;
   }
  
   public Object handleClosing(Invocation invocation) throws Throwable
   {     
      ConsumerState consumerState = getState(invocation);
                      
      // We make sure closing is called on the ServerConsumerEndpoint.
      // This returns us the last delivery id sent
     
      Long l  = (Long)invocation.invokeNext();
     
      long lastDeliveryId = l.longValue();
     
      // First we call close on the messagecallbackhandler which waits for onMessage invocations     
      // to complete and the last delivery to arrive
      consumerState.getMessageCallbackHandler().close(lastDeliveryId);
               
      SessionState sessionState = (SessionState)consumerState.getParent();
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();
                
      sessionState.removeCallbackHandler(consumerState.getMessageCallbackHandler());

      CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
      cm.unregisterHandler(consumerState.getConsumerID());
        
      //And then we cancel any messages still in the message callback handler buffer    
      consumerState.getMessageCallbackHandler().cancelBuffer();
                                  
      return l;
   }     
View Full Code Here

      return (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
   }
  
   private MessageCallbackHandler getMessageCallbackHandler(Invocation inv)
   {     
      ConsumerState state = (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
      return state.getMessageCallbackHandler();     
   }
View Full Code Here

      finally
      {
         tccc.restore();
      }

      ConsumerState state = (ConsumerState)((DelegateSupport)cons).getState();

      this.consumerID = state.getConsumerID();     
       
      this.maxDeliveries = state.getMaxDeliveries();
     
      if (subName != null)
      {
         queueName = MessageQueueNameHelper.createSubscriptionName(conn.getClientID(), subName);
      }
View Full Code Here

      int consumerID = consumerDelegate.getID();
      int bufferSize = consumerDelegate.getBufferSize();
      int maxDeliveries = consumerDelegate.getMaxDeliveries();

      ConsumerState consumerState =
         new ConsumerState(sessionState, consumerDelegate, dest, selector, noLocal,
                           subscriptionName, consumerID, connectionConsumer, bufferSize,
                           maxDeliveries);

      delegate.setState(consumerState);
      return consumerDelegate;
View Full Code Here

      // Create the message handler
      SessionState sessionState =
         (SessionState)((DelegateSupport)invocation.getTargetObject()).getState();
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();
      SessionDelegate sessionDelegate = (SessionDelegate)invocation.getTargetObject();
      ConsumerState consumerState = (ConsumerState)((DelegateSupport)consumerDelegate).getState();
      String consumerID = consumerState.getConsumerID();
      int prefetchSize = consumerState.getBufferSize();
      Executor executor = sessionState.getExecutor();
      int maxDeliveries = consumerState.getMaxDeliveries();
      long redeliveryDelay = consumerState.getRedeliveryDelay();
     
      FailoverCommandCenter fcc = connectionState.getFailoverCommandCenter();
     
      //We need the queue name for recovering any deliveries after failover
      String queueName = null;
      if (consumerState.getSubscriptionName() != null)
      {
         // I have to use the clientID from connectionDelegate instead of connectionState...
         // this is because when a pre configured CF is used we need to get the clientID from
         // server side.
         // This was a condition verified by the TCK and it was fixed as part of
         // http://jira.jboss.com/jira/browse/JBMESSAGING-939
         queueName = MessageQueueNameHelper.
            createSubscriptionName(((ConnectionDelegate)connectionState.getDelegate()).getClientID(),
                                   consumerState.getSubscriptionName());
      }
      else if (consumerState.getDestination().isQueue())
      {
         queueName = consumerState.getDestination().getName();
      }
     
      boolean autoFlowControl = ((Boolean)mi.getArguments()[5]).booleanValue();
     
      CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();

      ClientConsumer messageHandler =
         new ClientConsumer(isCC, sessionState.getAcknowledgeMode(),
                            sessionDelegate, consumerDelegate, consumerID, queueName,
                            prefetchSize, executor, maxDeliveries, consumerState.isShouldAck(),
                            redeliveryDelay, consumerState.getMaxRetryChangeRate(),
                            consumerState.getRetryChangeRateInterval(),
                            fcc != null, cm, consumerState.getMinTimeoutProcessTime());
     
      sessionState.addCallbackHandler(messageHandler);
     
      cm.registerHandler(consumerID, messageHandler);
        
      consumerState.setClientConsumer(messageHandler);
     
      if (autoFlowControl)
      {
        //Now we have finished creating the client consumer, we can tell the SCD
        //we are ready
View Full Code Here

      return consumerDelegate;
   }

   public Object handleClosing(Invocation invocation) throws Throwable
   {
      ConsumerState consumerState = getState(invocation);
      try
      {

         // We make sure closing is called on the ServerConsumerEndpoint.
         // This returns us the last delivery id sent

         Long l = (Long) invocation.invokeNext();

         long lastDeliveryId = l.longValue();

         // First we call close on the ClientConsumer which waits for onMessage invocations
         // to complete and the last delivery to arrive
         consumerState.getClientConsumer().close(lastDeliveryId);

         SessionState sessionState = (SessionState) consumerState.getParent();
         ConnectionState connectionState = (ConnectionState) sessionState.getParent();

         sessionState.removeCallbackHandler(consumerState.getClientConsumer());

         CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
         cm.unregisterHandler(consumerState.getConsumerID());

         //And then we cancel any messages still in the message callback handler buffer
         consumerState.getClientConsumer().cancelBuffer();

         return l;

      }
      catch (Exception proxiedException)
      {
         ConnectionState connectionState = (ConnectionState) (consumerState.getParent().getParent());
         // if ServerPeer is shutdown or
         // if there is no failover in place... we just close the consumerState as well
         if (proxiedException instanceof MessagingShutdownException ||
                 (connectionState.getFailoverCommandCenter() == null))


         {
            if (!consumerState.getClientConsumer().isClosed())
            {
               consumerState.getClientConsumer().close(-1);
            }
         }
         throw proxiedException;
      }
View Full Code Here

      return (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
   }
  
   private ClientConsumer getClientConsumer(Invocation inv)
   {     
      ConsumerState state = (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
      return state.getClientConsumer();     
   }
View Full Code Here

      String consumerID = consumerDelegate.getID();
      int bufferSize = consumerDelegate.getBufferSize();
      int maxDeliveries = consumerDelegate.getMaxDeliveries();
      long redeliveryDelay = consumerDelegate.getRedeliveryDelay();

      ConsumerState consumerState =
         new ConsumerState(sessionState, consumerDelegate, dest, selector, noLocal,
                           subscriptionName, consumerID, connectionConsumer, bufferSize,
                           maxDeliveries, redeliveryDelay);

      delegate.setState(consumerState);
      return consumerDelegate;
View Full Code Here

      // Create the message handler
      SessionState sessionState =
         (SessionState)((DelegateSupport)invocation.getTargetObject()).getState();
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();
      SessionDelegate sessionDelegate = (SessionDelegate)invocation.getTargetObject();
      ConsumerState consumerState = (ConsumerState)((DelegateSupport)consumerDelegate).getState();
      String consumerID = consumerState.getConsumerID();
      int prefetchSize = consumerState.getBufferSize();
      Executor executor = sessionState.getExecutor();
      int maxDeliveries = consumerState.getMaxDeliveries();
      long redeliveryDelay = consumerState.getRedeliveryDelay();
     
      //We need the queue name for recovering any deliveries after failover
      String queueName = null;
      if (consumerState.getSubscriptionName() != null)
      {
         // I have to use the clientID from connectionDelegate instead of connectionState...
         // this is because when a pre configured CF is used we need to get the clientID from
         // server side.
         // This was a condition verified by the TCK and it was fixed as part of
         // http://jira.jboss.com/jira/browse/JBMESSAGING-939
         queueName = MessageQueueNameHelper.
            createSubscriptionName(((ConnectionDelegate)connectionState.getDelegate()).getClientID(),
                                   consumerState.getSubscriptionName());
      }
      else if (consumerState.getDestination().isQueue())
      {
         queueName = consumerState.getDestination().getName();
      }
     
      boolean autoFlowControl = ((Boolean)mi.getArguments()[5]).booleanValue();
     
      ClientConsumer messageHandler =
         new ClientConsumer(isCC, sessionState.getAcknowledgeMode(),
                            sessionDelegate, consumerDelegate, consumerID, queueName,
                            prefetchSize, executor, maxDeliveries, consumerState.isShouldAck(),
                            redeliveryDelay);
     
      sessionState.addCallbackHandler(messageHandler);
     
      CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
      cm.registerHandler(consumerID, messageHandler);
        
      consumerState.setClientConsumer(messageHandler);
     
      if (autoFlowControl)
      {
        //Now we have finished creating the client consumer, we can tell the SCD
        //we are ready
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.state.ConsumerState

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.