Package org.jboss.jms.client.delegate

Examples of org.jboss.jms.client.delegate.ClientSessionDelegate


      {       
        conn = cf.createConnection();
       
        JBossSession sess = (JBossSession)conn.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
       
        ClientSessionDelegate del = (ClientSessionDelegate)sess.getDelegate();
       
        assertEquals(1000, del.getDupsOKBatchSize());
      }
      finally
      {
        if (conn != null)
        {
View Full Code Here


/* 123 */     return res;
/*     */   }
/*     */
/*     */   public Object handleCreateSessionDelegate(Invocation invocation) throws Throwable
/*     */   {
/* 128 */     ClientSessionDelegate sessionDelegate = (ClientSessionDelegate)invocation.invokeNext();
/* 129 */     DelegateSupport delegate = sessionDelegate;
/*     */
/* 131 */     ConnectionState connectionState = (ConnectionState)getState(invocation);
/*     */
/* 133 */     MethodInvocation mi = (MethodInvocation)invocation;
/* 134 */     boolean transacted = ((Boolean)mi.getArguments()[0]).booleanValue();
/* 135 */     int ackMode = ((Integer)mi.getArguments()[1]).intValue();
/* 136 */     boolean xa = ((Boolean)mi.getArguments()[2]).booleanValue();
/*     */
/* 138 */     SessionState sessionState = new SessionState(connectionState, sessionDelegate, transacted, ackMode, xa, sessionDelegate.getDupsOKBatchSize());
/*     */
/* 142 */     delegate.setState(sessionState);
/* 143 */     return delegate;
/*     */   }
View Full Code Here

/*     */
/* 211 */     this.npSendSequence = 0L;
/*     */
/* 216 */     this.executor.clearAllExceptCurrentTask();
/*     */
/* 218 */     ClientSessionDelegate newDelegate = (ClientSessionDelegate)newState.getDelegate();
/*     */
/* 220 */     for (Iterator i = getChildren().iterator(); i.hasNext(); )
/*     */     {
/* 222 */       HierarchicalState child = (HierarchicalState)i.next();
/*     */
/* 224 */       if ((child instanceof ConsumerState))
/*     */       {
/* 226 */         ConsumerState consState = (ConsumerState)child;
/* 227 */         ClientConsumerDelegate consDelegate = (ClientConsumerDelegate)consState.getDelegate();
/*     */
/* 230 */         ClientConsumerDelegate newConsDelegate = (ClientConsumerDelegate)newDelegate.createConsumerDelegate(consState.getDestination(), consState.getSelector(), consState.isNoLocal(), consState.getSubscriptionName(), consState.isConnectionConsumer(), true);
/*     */
/* 236 */         log.trace(this + " created new consumer " + newConsDelegate);
/*     */
/* 238 */         consDelegate.synchronizeWith(newConsDelegate);
/* 239 */         log.trace(this + " synchronized failover consumer " + consDelegate);
/*     */       }
/* 241 */       else if ((child instanceof ProducerState))
/*     */       {
/* 243 */         ProducerState prodState = (ProducerState)child;
/* 244 */         ClientProducerDelegate prodDelegate = (ClientProducerDelegate)prodState.getDelegate();
/*     */
/* 247 */         ClientProducerDelegate newProdDelegate = (ClientProducerDelegate)newDelegate.createProducerDelegate((JBossDestination)prodState.getDestination());
/*     */
/* 249 */         log.trace(this + " created new producer " + newProdDelegate);
/*     */
/* 251 */         prodDelegate.synchronizeWith(newProdDelegate);
/* 252 */         log.trace(this + " synchronized failover producer " + prodDelegate);
/*     */       }
/* 254 */       else if ((child instanceof BrowserState))
/*     */       {
/* 256 */         BrowserState browserState = (BrowserState)child;
/* 257 */         ClientBrowserDelegate browserDelegate = (ClientBrowserDelegate)browserState.getDelegate();
/*     */
/* 261 */         ClientBrowserDelegate newBrowserDelegate = (ClientBrowserDelegate)newDelegate.createBrowserDelegate(browserState.getJmsDestination(), browserState.getMessageSelector());
/*     */
/* 264 */         log.trace(this + " created new browser " + newBrowserDelegate);
/*     */
/* 266 */         browserDelegate.synchronizeWith(newBrowserDelegate);
/* 267 */         log.trace(this + " synchronized failover browser " + browserDelegate);
/*     */       }
/*     */     }
/*     */
/* 271 */     ConnectionState connState = (ConnectionState)getParent();
/* 272 */     ResourceManager rm = connState.getResourceManager();
/*     */
/* 275 */     rm.handleFailover(connState.getServerID(), oldSessionID, newState.sessionID);
/*     */
/* 277 */     List ackInfos = Collections.EMPTY_LIST;
/*     */
/* 279 */     if ((!isTransacted()) || ((isXA()) && (getCurrentTxId() == null)))
/*     */     {
/* 287 */       log.trace(this + " is not transacted (or XA with no transaction set), " + "retrieving deliveries from session state");
/*     */
/* 293 */       if (this.acknowledgeMode == 2)
/*     */       {
/* 295 */         for (Iterator i = getClientAckList().iterator(); i.hasNext(); )
/*     */         {
/* 297 */           DeliveryInfo info = (DeliveryInfo)i.next();
/* 298 */           if (!info.getMessageProxy().getMessage().isReliable())
/*     */           {
/* 300 */             i.remove();
/* 301 */             log.trace("removed non persistent delivery " + info);
/*     */           }
/*     */         }
/*     */
/* 305 */         ackInfos = getClientAckList();
/*     */       }
/*     */       else
/*     */       {
/* 309 */         DeliveryInfo autoAck = getAutoAckInfo();
/* 310 */         if (autoAck != null)
/*     */         {
/* 312 */           if (!autoAck.getMessageProxy().getMessage().isReliable())
/*     */           {
/* 315 */             setAutoAckInfo(null);
/*     */           }
/*     */           else
/*     */           {
/* 320 */             ackInfos = new ArrayList();
/* 321 */             ackInfos.add(autoAck);
/*     */           }
/*     */         }
/*     */       }
/*     */
/* 326 */       log.trace(this + " retrieved " + ackInfos.size() + " deliveries");
/*     */     }
/*     */     else
/*     */     {
/* 333 */       ackInfos = rm.getDeliveriesForSession(getSessionID());
/*     */     }
/*     */
/* 336 */     List recoveryInfos = new ArrayList();
/*     */     Iterator i;
/* 337 */     if (!ackInfos.isEmpty())
/*     */     {
/* 339 */       for (i = ackInfos.iterator(); i.hasNext(); )
/*     */       {
/* 341 */         DeliveryInfo del = (DeliveryInfo)i.next();
/* 342 */         DeliveryRecovery recInfo = new DeliveryRecovery(del.getMessageProxy().getDeliveryId(), del.getMessageProxy().getMessage().getMessageID(), del.getQueueName());
/*     */
/* 347 */         recoveryInfos.add(recInfo);
/*     */       }
/*     */
/*     */     }
/*     */
/* 354 */     log.trace(this + " sending delivery recovery " + recoveryInfos + " on failover");
/*     */
/* 357 */     if ((this.transacted) || (this.xa) || (this.acknowledgeMode == 2))
/*     */     {
/* 359 */       newDelegate.recoverDeliveries(recoveryInfos, oldSessionID);
/*     */     }
/*     */   }
View Full Code Here

/*     */
/* 162 */     for (Iterator i = getChildren().iterator(); i.hasNext(); )
/*     */     {
/* 164 */       SessionState sessionState = (SessionState)i.next();
/*     */
/* 166 */       ClientSessionDelegate sessionDelegate = (ClientSessionDelegate)sessionState.getDelegate();
/*     */
/* 169 */       ClientSessionDelegate newSessionDelegate = (ClientSessionDelegate)newDelegate.createSessionDelegate(sessionState.isTransacted(), sessionState.getAcknowledgeMode(), sessionState.isXA());
/*     */
/* 174 */       sessionDelegate.synchronizeWith(newSessionDelegate);
/*     */     }
/*     */
/* 178 */     this.fcc = newState.fcc;
View Full Code Here

/*     */
/* 266 */       Dispatcher.instance.registerTarget(sessionID, sessionAdvised);
/*     */
/* 268 */       log.trace("created and registered " + ep);
/*     */
/* 270 */       ClientSessionDelegate d = new ClientSessionDelegate(sessionID, this.dupsOKBatchSize);
/*     */
/* 272 */       log.trace("created " + d);
/*     */
/* 274 */       return d;
/*     */     }
View Full Code Here

/* 65 */     os.flush();
/*    */   }
/*    */
/*    */   public void read(DataInputStream is) throws Exception
/*    */   {
/* 70 */     this.del = new ClientSessionDelegate();
/*    */
/* 72 */     this.del.read(is);
/*    */   }
View Full Code Here

/*     */       {
/* 279 */         ConnectionState connState = (ConnectionState)state.getParent();
/*     */
/* 281 */         if (this.trace) log.trace("sending acknowlegment transactionally, queueing on resource manager");
/*     */
/* 287 */         ClientSessionDelegate connectionConsumerDelegate = (ClientSessionDelegate)info.getConnectionConsumerSession();
/*     */
/* 290 */         String sessionId = connectionConsumerDelegate != null ? connectionConsumerDelegate.getID() : state.getSessionID();
/*     */
/* 293 */         connState.getResourceManager().addAck(txID, sessionId, info);
/*     */       }
/*     */     }
/*     */
View Full Code Here

     
      // Connection
     
      public void testConnectionCreateSessionDelegateResponse() throws Exception
      {
         ClientSessionDelegate del = new ClientSessionDelegate("786", 1000);
        
         ResponseSupport resp =
            new ConnectionCreateSessionDelegateResponse(del);
                
         testPacket(resp, PacketSupport.RESP_CONNECTION_CREATESESSIONDELEGATE);                          
View Full Code Here

      // We need to clear anything waiting in the session executor - since there may be messages
      // from before failover waiting in there and we don't want them to get delivered after
      // failover.
      executor.clearAllExceptCurrentTask();
     
      ClientSessionDelegate newDelegate = (ClientSessionDelegate)newState.getDelegate();

      for (Iterator i = getChildren().iterator(); i.hasNext(); )
      {
         HierarchicalState child = (HierarchicalState)i.next();

         if (child instanceof ConsumerState)
         {
            ConsumerState consState = (ConsumerState)child;
            ClientConsumerDelegate consDelegate = (ClientConsumerDelegate)consState.getDelegate();

            // create a new consumer over the new session for each consumer on the old session
            ClientConsumerDelegate newConsDelegate = (ClientConsumerDelegate)newDelegate.
               createConsumerDelegate((JBossDestination)consState.getDestination(),
                                      consState.getSelector(),
                                      consState.isNoLocal(),
                                      consState.getSubscriptionName(),
                                      consState.isConnectionConsumer(), true);
            log.trace(this + " created new consumer " + newConsDelegate);

            consDelegate.synchronizeWith(newConsDelegate);
            log.trace(this + " synchronized failover consumer " + consDelegate);
         }
         else if (child instanceof ProducerState)
         {
            ProducerState prodState = (ProducerState)child;
            ClientProducerDelegate prodDelegate = (ClientProducerDelegate)prodState.getDelegate();

            // create a new producer over the new session for each producer on the old session
            ClientProducerDelegate newProdDelegate = (ClientProducerDelegate)newDelegate.
               createProducerDelegate((JBossDestination)prodState.getDestination());
            log.trace(this + " created new producer " + newProdDelegate);

            prodDelegate.synchronizeWith(newProdDelegate);
            log.trace(this + " synchronized failover producer " + prodDelegate);
         }
         else if (child instanceof BrowserState)
         {
            BrowserState browserState = (BrowserState)child;
            ClientBrowserDelegate browserDelegate =
               (ClientBrowserDelegate)browserState.getDelegate();

            // create a new browser over the new session for each browser on the old session
            ClientBrowserDelegate newBrowserDelegate = (ClientBrowserDelegate)newDelegate.
               createBrowserDelegate(browserState.getJmsDestination(),
                                     browserState.getMessageSelector());
            log.trace(this + " created new browser " + newBrowserDelegate);

            browserDelegate.synchronizeWith(newBrowserDelegate);
            log.trace(this + " synchronized failover browser " + browserDelegate);
         }
      }

      ConnectionState connState = (ConnectionState)getParent();
      ResourceManager rm = connState.getResourceManager();

      // We need to failover from one session ID to another in the resource manager
      rm.handleFailover(connState.getServerID(), oldSessionID, newState.sessionID);

      List ackInfos = Collections.EMPTY_LIST;

      if (!isTransacted() || (isXA() && getCurrentTxId() == null))
      {
         // TODO - the check "(isXA() && getCurrentTxId() == null)" shouldn't be necessary any more
         // since xa sessions no longer fall back to non transacted
        
         // Non transacted session or an XA session with no transaction set (it falls back
         // to AUTO_ACKNOWLEDGE)

         log.trace(this + " is not transacted (or XA with no transaction set), " +
                   "retrieving deliveries from session state");

         // We remove any unacked non-persistent messages - this is because we don't want to ack
         // them since the server won't know about them and will get confused

         if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
         {
            for(Iterator i = getClientAckList().iterator(); i.hasNext(); )
            {
               DeliveryInfo info = (DeliveryInfo)i.next();
               if (!info.getMessageProxy().getMessage().isReliable())
               {
                  i.remove();
                  log.trace("removed non persistent delivery " + info);
               }
            }

            ackInfos = getClientAckList();
         }
         else
         {
            DeliveryInfo autoAck = getAutoAckInfo();
            if (autoAck != null)
            {
               if (!autoAck.getMessageProxy().getMessage().isReliable())
               {
                  // unreliable, discard
                  setAutoAckInfo(null);
               }
               else
               {
                  // reliable
                  ackInfos = new ArrayList();
                  ackInfos.add(autoAck);
               }
            }
         }

         log.trace(this + " retrieved " + ackInfos.size() + " deliveries");
      }
      else
      {
         // Transacted session - we need to get the acks from the resource manager. BTW we have
         // kept the old resource manager.

         ackInfos = rm.getDeliveriesForSession(getSessionID());
      }

      List recoveryInfos = new ArrayList();
      if (!ackInfos.isEmpty())
      {        
         for (Iterator i = ackInfos.iterator(); i.hasNext(); )
         {
            DeliveryInfo del = (DeliveryInfo)i.next();
            DeliveryRecovery recInfo =
               new DeliveryRecovery(del.getMessageProxy().getDeliveryId(),
                                    del.getMessageProxy().getMessage().getMessageID(),
                                    del.getQueueName());

            recoveryInfos.add(recInfo);
         }        
      }

      //Note! We ALWAYS call recoverDeliveries even if there are no deliveries since it also does other stuff
      //like remove from recovery Area refs corresponding to messages in client consumer buffers
     
      log.trace(this + " sending delivery recovery " + recoveryInfos + " on failover");
     
      //Note we only recover sessions that are transacted or client ack
      if (transacted || xa || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
      {
        newDelegate.recoverDeliveries(recoveryInfos, oldSessionID);
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.delegate.ClientSessionDelegate

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.