Package org.jboss.jms.client.state

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


         }
         // once we enlist ensure that the 5 acks are merged ok, the first timne we do this there is nothing to merge in
         // the global tx
         // so all acks are just copied
         trans.enlistResource(res1);
         SessionState sstate = (SessionState)((DelegateSupport)sess1.getDelegate()).getState();
         ClientTransaction clientTransaction = rm.getTx(sstate.getCurrentTxId());
         assertEquals("to many session states", clientTransaction.getSessionStates().size(), 1);
         ClientTransaction.SessionTxState sessionTxState = (ClientTransaction.SessionTxState)clientTransaction.getSessionStates()
                                                                                                              .get(0);
         assertEquals("wrong number of acks", 5, sessionTxState.getAcks().size());

         trans.delistResource(res1, XAResource.TMSUCCESS);
         for (int i = 5; i < 10; i++)
         {
            TextMessage textMessage = (TextMessage)cons.receive();
            assertEquals("delistedwork" + i, textMessage.getText());
         }
         // now reenlist and make sure that there are now 10 acks, this time around a merge will be done with the first
         // 5 acks
         //
         trans.enlistResource(res1);

         clientTransaction = rm.getTx(sstate.getCurrentTxId());
         assertEquals("to many session states", clientTransaction.getSessionStates().size(), 1);
         sessionTxState = (ClientTransaction.SessionTxState)clientTransaction.getSessionStates().get(0);
         assertEquals("wrong number of acks", 10, sessionTxState.getAcks().size());

         tm.commit();
View Full Code Here


         tm.begin();

         Transaction trans = tm.getTransaction();

         JBossSession session = (JBossSession)xasession;
         SessionState state = (SessionState)((DelegateSupport)session.getDelegate()).getState();

         // Validates TX convertion
         assertTrue(state.getCurrentTxId() instanceof LocalTx);

         // Enlist the transaction... as supposed to be happening on JBossAS with the
         // default listener (enlist happening after message is received)
         trans.enlistResource(resource);

         // Validates TX convertion
         assertFalse(state.getCurrentTxId() instanceof LocalTx);

         trans.delistResource(resource, XAResource.TMSUCCESS);

         trans.commit();
View Full Code Here

      ConsumerDelegate consumerDelegate = (ConsumerDelegate)invocation.invokeNext();

      boolean isCC = ((Boolean)mi.getArguments()[4]).booleanValue();

      // 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);
     
View Full Code Here

         // 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
View Full Code Here

      MethodInvocation mi = (MethodInvocation)invocation;
           
      //This is the delegate for the session from the pool
      SessionDelegate del = (SessionDelegate)mi.getTargetObject();
     
      SessionState state = getState(invocation);
     
      int ackMode = state.getAcknowledgeMode();

      LinkedList msgs = state.getASFMessages();
     
      while (msgs.size() > 0)
      {
         AsfMessageHolder holder = (AsfMessageHolder)msgs.removeFirst();

         if (trace) { log.trace("sending " + holder.msg + " to the message listener" ); }

         ClientConsumer.callOnMessageStatic(del, state.getDistinguishedListener(), holder.consumerID,
                                              holder.queueName, false,
                                              holder.msg, ackMode, holder.maxDeliveries,
                                              holder.connectionConsumerDelegate, holder.shouldAck);                         
      }
     
View Full Code Here

      boolean oneway = !(m.isReliable() || strictTck);
     
      long sequence = -1;
      if (oneway)
      {
         SessionState sstate = (SessionState)state;
         sequence = sstate.getNPSendSequence();
         sstate.incNpSendSequence();
      }
     
      RequestSupport req = new SessionSendRequest(id, version, m, checkForDuplicates, oneway, sequence);

      if (oneway)
View Full Code Here

      if (mi.getArguments().length >= 4)
      {
         isCC = ((Boolean)mi.getArguments()[3]).booleanValue();
      }

      SessionState sessionState =
         new SessionState(connectionState, sessionDelegate, transacted,
                          ackMode, xa, sessionDelegate.getDupsOKBatchSize(),
                          connectionState.isEnableOrderingGroup(), connectionState.getDefaultOrderingGroupName(), isCC);

      delegate.setState(sessionState);
      return delegate;
View Full Code Here

   public Object handleCreateConsumerDelegate(Invocation invocation) throws Throwable
   {
      ClientConsumerDelegate consumerDelegate = (ClientConsumerDelegate)invocation.invokeNext();
      DelegateSupport delegate = (DelegateSupport)consumerDelegate;

      SessionState sessionState = (SessionState)getState(invocation);

      MethodInvocation mi = (MethodInvocation)invocation;
      JBossDestination dest = (JBossDestination)mi.getArguments()[0];
      String selector = (String)mi.getArguments()[1];
      boolean noLocal = ((Boolean)mi.getArguments()[2]).booleanValue();
View Full Code Here

      // ProducerDelegates are not created on the server

      ProducerDelegate producerDelegate = new ClientProducerDelegate();
      DelegateSupport delegate = (DelegateSupport)producerDelegate;

      SessionState sessionState = (SessionState)getState(invocation);

      MethodInvocation mi = (MethodInvocation)invocation;
      Destination dest = ((Destination)mi.getArguments()[0]);

      ProducerState producerState = new ProducerState(sessionState, producerDelegate, dest);

      if (sessionState.isEnableOrderingGroup())
      {
         producerState.setOrderingGroupEnabled(true);
         producerState.setOrderingGroupName(sessionState.getDefaultOrderingGroupName());
      }
      delegate.setState(producerState);

      // send an arbitrary invocation into the producer delegate, this will trigger AOP stack
      // initialization and AOP aspect class loading, using the "good" class loader, which is set
View Full Code Here

      MethodInvocation mi = (MethodInvocation)invocation;

      ClientBrowserDelegate browserDelegate = (ClientBrowserDelegate)invocation.invokeNext();
      DelegateSupport delegate = (DelegateSupport)browserDelegate;

      SessionState sessionState = (SessionState)getState(invocation);

      JBossDestination destination = (JBossDestination)mi.getArguments()[0];
      String selector = (String)mi.getArguments()[1];

      BrowserState state =
View Full Code Here

TOP

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

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.