Package org.jboss.jms.client

Examples of org.jboss.jms.client.JBossConnection


     
      try
      {
         conn = cf.createConnection();
        
         JBossConnection jbConn = (JBossConnection)conn;
        
         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
        
         ConnectionState state = (ConnectionState)del.getState();
        
         ResourceManager rm = state.getResourceManager();
        
View Full Code Here


     
      try
      {
         conn = cf.createConnection();
        
         JBossConnection jbConn = (JBossConnection)conn;
        
         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
        
         ConnectionState state = (ConnectionState)del.getState();
        
         ResourceManager rm = state.getResourceManager();
        
View Full Code Here

         conn.close();

         conn = factory.createConnection(); //connection on server 1

         JBossConnection jbc = (JBossConnection)conn;

         ClientConnectionDelegate del = (ClientConnectionDelegate)jbc.getDelegate();

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

         int initialServerID = state.getServerID();
View Full Code Here

         conn.close();

         conn = factory.createConnection(); //connection on server 1

         JBossConnection jbc = (JBossConnection)conn;

         ClientConnectionDelegate del = (ClientConnectionDelegate)jbc.getDelegate();

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

         int initialServerID = state.getServerID();
View Full Code Here

      Destination destination = (Destination) topic[1];

      Connection conn1 = cf.createConnection();
      Connection conn2 = cf.createConnection();

      JBossConnection conn =
         (JBossConnection) getConnection(new Connection[]{conn1, conn2}, 1);

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

      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");
      JBossMessageConsumer jbossConsumerHA = (JBossMessageConsumer) consumerHA;

      org.jboss.jms.client.delegate.ClientConsumerDelegate clientDelegate =
         (org.jboss.jms.client.delegate.ClientConsumerDelegate) jbossConsumerHA.getDelegate();
      ConsumerState consumerState = (ConsumerState) clientDelegate.getState();

      log.info("subscriptionName=" + consumerState.getSubscriptionName());

      log.info(">>Creating Producer");
      MessageProducer producer = session.createProducer(destination);
      log.info(">>creating Message");
      Message message = session.createTextMessage("Hello Before");
      log.info(">>sending Message");
      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);
View Full Code Here

      if (!ServerManagement.isRemote())
      {
         return;
      }

      JBossConnection connection = null;

      try
      {
         connection = (JBossConnection)cf.createConnection();
         connection.start();

         ClientConnectionDelegate delegate = (ClientConnectionDelegate)connection.getDelegate();
         JMSRemotingConnection remotingConnection = delegate.getRemotingConnection();
         Client client = remotingConnection.getRemotingClient();

         Field field = JMSRemotingConnection.class.getDeclaredField("serverLocator");
         field.setAccessible(true);
         InvokerLocator locator = (InvokerLocator)field.get(remotingConnection);
         String transport = locator.getProtocol();

         if (!"http".equals(transport))
         {
            // not interesting
            return;
         }

         field = Client.class.getDeclaredField("callbackPollers");
         field.setAccessible(true);
         Map callbackPollers = (Map)field.get(client);
         assertEquals(1, callbackPollers.size());

         CallbackPoller callbackPoller = (CallbackPoller)callbackPollers.values().iterator().next();

         field = CallbackPoller.class.getDeclaredField("pollPeriod");
         field.setAccessible(true);
         Long pollPeriod = (Long)field.get(callbackPoller);
         assertEquals(ServiceContainer.HTTP_CONNECTOR_CALLBACK_POLL_PERIOD, pollPeriod.longValue());
      }
      finally
      {
         if (connection != null)
         {
            connection.close();
         }
      }
   }
View Full Code Here

      if (!ServerManagement.isRemote())
      {
         return;
      }

      JBossConnection connection = null;

      try
      {
         String address = InetAddress.getLocalHost().getHostAddress();
         System.setProperty("jboss.messaging.callback.bind.address", address);
        
         int freePort = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName());
         System.setProperty("jboss.messaging.callback.bind.port", Integer.toString(freePort));

         String pollPeriod = "654";
         System.setProperty("jboss.messaging.callback.pollPeriod", pollPeriod);

         System.setProperty("jboss.messaging.callback.reportPollingStatistics", "true");
        
         connection = (JBossConnection)cf.createConnection();
         connection.start();

         ClientConnectionDelegate delegate = (ClientConnectionDelegate)connection.getDelegate();
         JMSRemotingConnection remotingConnection = delegate.getRemotingConnection();
         Client client = remotingConnection.getRemotingClient();

         Field field = JMSRemotingConnection.class.getDeclaredField("serverLocator");
         field.setAccessible(true);
         InvokerLocator locator = (InvokerLocator)field.get(remotingConnection);
         String transport = locator.getProtocol();

         if ("socket".equals(transport)
               || "sslsocket".equals(transport)
               || "bisocket".equals(transport)
               || "sslbisocket".equals(transport))
         {
            field = Client.class.getDeclaredField("callbackConnectors");
            field.setAccessible(true);
            Map callbackConnectors = (Map)field.get(client);

            InvokerCallbackHandler callbackHandler = remotingConnection.getCallbackManager();
            Connector connector = (Connector)callbackConnectors.get(callbackHandler);
            locator = new InvokerLocator(connector.getInvokerLocator());
            assertEquals(address, locator.getHost());
            assertEquals(freePort, locator.getPort());
         }
         else if ("http".equals(transport))
         {
            field = Client.class.getDeclaredField("callbackPollers");
            field.setAccessible(true);
            Map callbackPollers = (Map)field.get(client);
            assertEquals(1, callbackPollers.size());

            CallbackPoller callbackPoller =
               (CallbackPoller)callbackPollers.values().iterator().next();

            field = CallbackPoller.class.getDeclaredField("pollPeriod");
            field.setAccessible(true);

            assertEquals(pollPeriod, ((Long)field.get(callbackPoller)).toString());
           
            field = CallbackPoller.class.getDeclaredField("reportStatistics");
            field.setAccessible(true);
            assertEquals(true, ((Boolean) field.get(callbackPoller)).booleanValue());
         }
         else
         {
            fail("Unrecognized transport: " + transport);
         }
      }
      finally
      {
         if (connection != null)
         {
            connection.close();
         }
      }
   }
View Full Code Here

      if (!(conn instanceof JBossConnection))
      {
         throw new Exception("Connection not an instance of JBossConnection");
      }
     
      JBossConnection jbconn = (JBossConnection)conn;
     
      DelegateSupport del = (DelegateSupport)jbconn.getDelegate();
     
      ConnectionState state = (ConnectionState)del.getState();
     
      return state.getServerID();
   }
View Full Code Here

  
  
  
   public void testFailoverFloodTwoServers() throws Exception
   {
      JBossConnection conn = null;

      try
      {
         conn = (JBossConnection)this.createConnectionOnServer(cf, 1);

         Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

         Session sessCons = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

         MessageConsumer cons = sessCons.createConsumer(queue[1]);

         MyListener list = new MyListener();

         cons.setMessageListener(list);

         conn.start();

         MessageProducer prod = sessSend.createProducer(queue[1]);

         prod.setDeliveryMode(DeliveryMode.PERSISTENT);

         int count = 0;
        
         Killer killer = new Killer();
        
         Thread t = new Thread(killer);
        
         t.start();
        
         while (!killer.isDone())
         {
            TextMessage tm = sessSend.createTextMessage("message " + count);
            tm.setIntProperty("cnt", count);

            prod.send(tm);
           
            if (count % 100 == 0)
            {
               log.info("sent " + count + " server id " + conn.getServerID());
            }
           
            count++;
           
            Thread.sleep(5);
         }
        
         log.info("done send");
        
         log.info("Waiting to join thread");
         t.join(5 * 60 * 60 * 1000);
         log.info("joined");
        
         if (killer.failed)
         {
            fail();
         }
        
         //We check that we received all the message
         //we allow for duplicates, see http://jira.jboss.org/jira/browse/JBMESSAGING-604
         //We are using auto_ack with a listener so duplicates are ok
        
         if (!list.waitFor(count - 1))
         {
           fail("Timed out waiting for message");
         }
        
         conn.close();
         conn = null;
        
                 
         count = 0;
         Iterator iter = list.msgs.iterator();
         while (iter.hasNext())
         {
            Integer i = (Integer)iter.next();
           
            if (i.intValue() != count)
            {
               fail("Missing message " + i);
            }
            count++;
         }
        
         if (list.failed)
         {
            fail();
         }
      }
      catch (Exception e)
      {
         log.error("Failed", e);
         throw e;
      }
      finally
      {        
         if (conn != null)
         {
            log.info("closing connection");
            try
            {
               conn.close();
            }
            catch (Exception ignore)
            {
            }
            log.info("closed connection");
View Full Code Here

      try
      {

         conn = cf.createXAConnection();

         JBossConnection jbConn = (JBossConnection)conn;

         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();

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

         ResourceManager rm = state.getResourceManager();
View Full Code Here

TOP

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

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.