Package org.jboss.jms.client.state

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


      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();
      QueuedExecutor sessionExecutor = 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, sessionExecutor, maxDeliveries, consumerState.isShouldAck(),
                            autoFlowControl, 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

      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

/* 160 */     String consumerID = consumerDelegate.getID();
/* 161 */     int bufferSize = consumerDelegate.getBufferSize();
/* 162 */     int maxDeliveries = consumerDelegate.getMaxDeliveries();
/* 163 */     long redeliveryDelay = consumerDelegate.getRedeliveryDelay();
/*     */
/* 165 */     ConsumerState consumerState = new ConsumerState(sessionState, consumerDelegate, dest, selector, noLocal, subscriptionName, consumerID, connectionConsumer, bufferSize, maxDeliveries, redeliveryDelay);
/*     */
/* 170 */     delegate.setState(consumerState);
/* 171 */     return consumerDelegate;
/*     */   }
View Full Code Here

/*     */
/* 124 */     this.sess = conn.createSessionDelegate(false, 2, false);
/*     */
/* 126 */     this.cons = this.sess.createConsumerDelegate(dest, messageSelector, false, subName, true, true);
/*     */
/* 128 */     ConsumerState state = (ConsumerState)((DelegateSupport)this.cons).getState();
/*     */
/* 130 */     this.consumerID = state.getConsumerID();
/*     */
/* 132 */     this.maxDeliveries = state.getMaxDeliveries();
/*     */
/* 134 */     this.shouldAck = state.isShouldAck();
/*     */
/* 136 */     if (subName != null)
/*     */     {
/* 138 */       this.queueName = MessageQueueNameHelper.createSubscriptionName(conn.getClientID(), subName);
/*     */     }
View Full Code Here

/*     */
/*  78 */     SessionState sessionState = (SessionState)((DelegateSupport)invocation.getTargetObject()).getState();
/*     */
/*  80 */     ConnectionState connectionState = (ConnectionState)sessionState.getParent();
/*  81 */     SessionDelegate sessionDelegate = (SessionDelegate)invocation.getTargetObject();
/*  82 */     ConsumerState consumerState = (ConsumerState)((DelegateSupport)consumerDelegate).getState();
/*  83 */     String consumerID = consumerState.getConsumerID();
/*  84 */     int prefetchSize = consumerState.getBufferSize();
/*  85 */     QueuedExecutor sessionExecutor = sessionState.getExecutor();
/*  86 */     int maxDeliveries = consumerState.getMaxDeliveries();
/*  87 */     long redeliveryDelay = consumerState.getRedeliveryDelay();
/*     */
/*  90 */     String queueName = null;
/*  91 */     if (consumerState.getSubscriptionName() != null)
/*     */     {
/*  98 */       queueName = MessageQueueNameHelper.createSubscriptionName(((ConnectionDelegate)connectionState.getDelegate()).getClientID(), consumerState.getSubscriptionName());
/*     */     }
/* 102 */     else if (consumerState.getDestination().isQueue())
/*     */     {
/* 104 */       queueName = consumerState.getDestination().getName();
/*     */     }
/*     */
/* 107 */     boolean autoFlowControl = ((Boolean)mi.getArguments()[5]).booleanValue();
/*     */
/* 109 */     ClientConsumer messageHandler = new ClientConsumer(isCC, sessionState.getAcknowledgeMode(), sessionDelegate, consumerDelegate, consumerID, queueName, prefetchSize, sessionExecutor, maxDeliveries, consumerState.isShouldAck(), autoFlowControl, redeliveryDelay);
/*     */
/* 115 */     sessionState.addCallbackHandler(messageHandler);
/*     */
/* 117 */     CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
/* 118 */     cm.registerHandler(consumerID, messageHandler);
/*     */
/* 120 */     consumerState.setClientConsumer(messageHandler);
/*     */
/* 122 */     if (autoFlowControl)
/*     */     {
/* 126 */       consumerDelegate.changeRate(1.0F);
/*     */     }
View Full Code Here

/* 129 */     return consumerDelegate;
/*     */   }
/*     */
/*     */   public Object handleClosing(Invocation invocation) throws Throwable
/*     */   {
/* 134 */     ConsumerState consumerState = getState(invocation);
/*     */     try
/*     */     {
/* 141 */       Long l = (Long)invocation.invokeNext();
/*     */
/* 143 */       long lastDeliveryId = l.longValue();
/*     */
/* 147 */       consumerState.getClientConsumer().close(lastDeliveryId);
/*     */
/* 149 */       SessionState sessionState = (SessionState)consumerState.getParent();
/* 150 */       ConnectionState connectionState = (ConnectionState)sessionState.getParent();
/*     */
/* 152 */       sessionState.removeCallbackHandler(consumerState.getClientConsumer());
/*     */
/* 154 */       CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
/* 155 */       cm.unregisterHandler(consumerState.getConsumerID());
/*     */
/* 158 */       consumerState.getClientConsumer().cancelBuffer();
/*     */
/* 160 */       return l;
/*     */     }
/*     */     catch (Exception proxiedException)
/*     */     {
/* 165 */       ConnectionState connectionState = (ConnectionState)(ConnectionState)consumerState.getParent().getParent();
/*     */
/* 168 */       if (((proxiedException instanceof MessagingShutdownException)) || (connectionState.getFailoverCommandCenter() == null))
/*     */       {
/* 173 */         if (!consumerState.getClientConsumer().isClosed())
/*     */         {
/* 175 */           consumerState.getClientConsumer().close(-1L);
/*     */         }
/*     */       }
/*     */     }
/* 178 */     throw proxiedException;
/*     */   }
View Full Code Here

/* 236 */     return (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
/*     */   }
/*     */
/*     */   private ClientConsumer getClientConsumer(Invocation inv)
/*     */   {
/* 241 */     ConsumerState state = (ConsumerState)((DelegateSupport)inv.getTargetObject()).getState();
/* 242 */     return state.getClientConsumer();
/*     */   }
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();
      QueuedExecutor sessionExecutor = 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, sessionExecutor, maxDeliveries, consumerState.isShouldAck(),
                            autoFlowControl, 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.