Package org.jboss.jms.client

Examples of org.jboss.jms.client.JBossSession


      }
   }
  
   protected void tweakXASession(XASession sess)
   {
      JBossSession jsess = (JBossSession)sess;
     
      SessionState sstate = (SessionState)((DelegateSupport)jsess.getDelegate()).getState();
     
      sstate.setTreatAsNonTransactedWhenNotEnlisted(false);
   }
View Full Code Here


    * This test was created as per http://jira.jboss.org/jira/browse/JBMESSAGING-685.
    */
   public void testEmptyCommit() throws Exception
   {
      Connection conn = cf.createConnection();
      JBossSession session = (JBossSession)conn.createSession(true, Session.SESSION_TRANSACTED);
      session.commit();
      conn.close();
   }
View Full Code Here

      conn.setClientID("testClient");
      conn.start();

      try
      {
         JBossSession session = (JBossSession) conn.createSession(true, Session.SESSION_TRANSACTED);
         ClientSessionDelegate clientSessionDelegate = (ClientSessionDelegate) session.getDelegate();
         SessionState sessionState = (SessionState) clientSessionDelegate.getState();

         MessageConsumer consumerHA = session.createDurableSubscriber((Topic) destination, "T1");

         MessageProducer producer = session.createProducer(destination);
         Message message = session.createTextMessage("Hello Before");
         producer.send(message);
         session.commit();

         receiveMessage("consumerHA", consumerHA, true, false);

         session.commit();
         //if (true) return;

         Object txID = sessionState.getCurrentTxId();

         producer.send(session.createTextMessage("Hello again before failover"));

         ClientConnectionDelegate delegate = (ClientConnectionDelegate) conn.getDelegate();

         JMSRemotingConnection originalRemoting = delegate.getRemotingConnection();

         ServerManagement.kill(1);

         // wait for the client-side failover to complete

         while(true)
         {
            FailoverEvent event = failoverListener.getEvent(30000);
            if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
            {
               break;
            }
            if (event == null)
            {
               fail("Did not get expected FAILOVER_COMPLETED event");
            }
         }
         // if failover happened, this object was replaced
         assertNotSame(originalRemoting, delegate.getRemotingConnection());

         message = session.createTextMessage("Hello After");
         producer.send(message);

         assertEquals(txID, sessionState.getCurrentTxId());
         session.commit();

         receiveMessage("consumerHA", consumerHA, true, false);
         receiveMessage("consumerHA", consumerHA, true, false);
         receiveMessage("consumerHA", consumerHA, true, true);

         session.commit();

         consumerHA.close();
         session.unsubscribe("T1");
      }
      finally
      {
         if (conn!=null)
         {
View Full Code Here

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

/*      */         }
/*      */       }
/*      */
/*  991 */       if ((this.forwardMode == 0) && ((this.sourceSession instanceof JBossSession)))
/*      */       {
/*  993 */         JBossSession jsession = (JBossSession)this.sourceSession;
/*      */
/*  995 */         SessionState sstate = (SessionState)((DelegateSupport)jsession.getDelegate()).getState();
/*      */
/*  997 */         sstate.setTreatAsNonTransactedWhenNotEnlisted(false);
/*      */       }
/*      */
/* 1000 */       if (this.subName == null)
View Full Code Here

/*     */
/* 116 */     if (this.trace) log.trace(this + " starting");
/*     */
/* 118 */     if (!this.xa)
/*     */     {
/* 125 */       JBossSession sess = (JBossSession)this.sourceConnection.createSession(false, 2);
/*     */
/* 127 */       this.sourceSession = sess.getDelegate();
/*     */
/* 130 */       sess = (JBossSession)this.localConnection.createSession(false, 1);
/*     */
/* 132 */       this.localSession = sess.getDelegate();
/*     */     }
/*     */     else
/*     */     {
/* 136 */       JBossSession sess = (JBossSession)this.sourceConnection.createXASession();
/*     */
/* 138 */       this.sourceSession = sess.getDelegate();
/*     */
/* 140 */       sess = (JBossSession)this.localConnection.createXASession();
/*     */
/* 142 */       this.localSession = sess.getDelegate();
/*     */     }
/*     */
/* 145 */     JBossDestination dest = new JBossQueue(this.localQueue.getName(), true);
/*     */
/* 147 */     this.producer = this.localSession.createProducerDelegate(dest);
View Full Code Here

      //If not XA then we use a client ack session for consuming - this allows us to get the message, send it to the destination
      //then ack the message.
      //This means that if a failure occurs between sending and acking the message won't be lost but may get delivered
      //twice - i.e we have dups_ok behaviour
     
      JBossSession sess = (JBossSession)sourceConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   
      sourceSession = (SessionDelegate)sess.getDelegate();
     
     
      sess = (JBossSession)localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      localSession = (SessionDelegate)sess.getDelegate();
    }
    else
    {
      JBossSession sess = (JBossSession)sourceConnection.createXASession();
     
      sourceSession = (SessionDelegate)sess.getDelegate();
     
      sess = (JBossSession)localConnection.createXASession();
     
      localSession = (SessionDelegate)sess.getDelegate();
    }
           
    JBossDestination dest = new JBossQueue(localQueue.getName(), true);
       
    producer = localSession.createProducerDelegate(dest);
View Full Code Here

         ConnectionState state = (ConnectionState)del.getState();

         ResourceManager rm = state.getResourceManager();

         //Create a session
         JBossSession sess1 = (JBossSession) conn.createXASession();
         DummyListener listener = new DummyListener();
         sess1.setMessageListener(listener);
         conn.start();
         MessagingXAResource res1 = (MessagingXAResource) sess1.getXAResource();
         tm.begin();

         Transaction trans = tm.getTransaction();
         trans.enlistResource(res1);
         trans.delistResource(res1, XAResource.TMSUCCESS);
         MessageProducer p = sess1.createProducer(queue1);
         MessageConsumer cons = sess1.createConsumer(queue1);
         conn.start();
         //send 10 messages
         for(int i = 0; i < 10; i++)
         {
            TextMessage message = sess1.createTextMessage("delistedwork" + i);
            p.send(message);
         }
         //now receive 5
         for(int i = 0; i < 5; i++)
         {
            TextMessage textMessage = (TextMessage) cons.receive();
            assertEquals("delistedwork" + i, textMessage.getText());
         }
         //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());
View Full Code Here

         // Starts a new transaction
         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
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.JBossSession

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.