当前位置: 首页>>代码示例>>Java>>正文


Java ServerLocator.close方法代码示例

本文整理汇总了Java中org.apache.activemq.artemis.api.core.client.ServerLocator.close方法的典型用法代码示例。如果您正苦于以下问题:Java ServerLocator.close方法的具体用法?Java ServerLocator.close怎么用?Java ServerLocator.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.artemis.api.core.client.ServerLocator的用法示例。


在下文中一共展示了ServerLocator.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDiscoveryConstructor

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testDiscoveryConstructor() throws Exception {
   ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(groupConfiguration);

   assertFactoryParams(locator, null, groupConfiguration, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE, ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND, ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS);

   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession(false, true, true);
   Assert.assertNotNull(session);
   session.close();
   testSettersThrowException(cf);

   cf.close();

   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:SessionFactoryTest.java

示例2: testProducerWithSmallWindowSizeAndLargeMessage

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testProducerWithSmallWindowSizeAndLargeMessage() throws Exception {
   final CountDownLatch latch = new CountDownLatch(1);
   server.getRemotingService().addIncomingInterceptor(new Interceptor() {
      @Override
      public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException {
         if (packet.getType() == PacketImpl.SESS_SEND) {
            latch.countDown();
         }
         return true;
      }
   });
   ServerLocator locator = createInVMNonHALocator().setConfirmationWindowSize(100);
   ClientSessionFactory cf = locator.createSessionFactory();
   ClientSession session = cf.createSession(false, true, true);
   ClientProducer producer = session.createProducer(QUEUE);
   ClientMessage message = session.createMessage(true);
   byte[] body = new byte[1000];
   message.getBodyBuffer().writeBytes(body);
   producer.send(message);
   Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
   session.close();
   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:ProducerTest.java

示例3: testTotalConnectionCount

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testTotalConnectionCount() throws Exception {
   final int CONNECTION_COUNT = 100;

   ActiveMQServerControl serverControl = createManagementControl();

   ServerLocator locator = createInVMNonHALocator();
   for (int i = 0; i < CONNECTION_COUNT; i++) {
      createSessionFactory(locator).close();
   }

   assertEquals(CONNECTION_COUNT + (usingCore() ? 1 : 0), serverControl.getTotalConnectionCount());
   assertEquals((usingCore() ? 1 : 0), serverControl.getConnectionCount());

   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:ActiveMQServerControlTest.java

示例4: verifyServer

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
public void verifyServer() throws Exception {
   ServerLocator locator;
   ClientSessionFactory factory;
   ClientSession session;

   ActiveMQServer server = PagingWithFailoverServer.createServer(getTestDir(), PORT1, PORT2, false);

   server.start();

   waitForServerToStart(server);
   Queue queue = server.locateQueue(SimpleString.toSimpleString("cons2"));

   int messageCount = getMessageCount(queue);

   assertTrue(messageCount >= 0);

   locator = SpawnedServerSupport.createLocator(PORT1).setInitialConnectAttempts(100).setReconnectAttempts(300).setRetryInterval(100);

   factory = locator.createSessionFactory();

   session = factory.createSession();
   session.start();

   try {
      drainConsumer(session.createConsumer("cons2"), "cons2", messageCount);
   } finally {
      session.close();
      factory.close();
      locator.close();
      server.stop();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:33,代码来源:PagingWithFailoverAndCountersTest.java

示例5: scaleDown

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
protected void scaleDown(ScaleDownHandler handler) throws Exception {
   SimpleString address = new SimpleString("testQueue");
   HashMap<String, Object> params = new HashMap<>();
   params.put(TransportConstants.SERVER_ID_PROP_NAME, "2");
   Configuration config = createDefaultInVMConfig(2).clearAcceptorConfigurations().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName(), params)).setSecurityEnabled(false);
   ActiveMQServer server2 = addServer(ActiveMQServers.newActiveMQServer(config, null, true));

   this.conf.clearConnectorConfigurations().addConnectorConfiguration("server2-connector", new TransportConfiguration(INVM_CONNECTOR_FACTORY, params));

   server2.start();
   server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
   server.createQueue(address, RoutingType.ANYCAST, address, null, true, false, -1, false, false);
   server2.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
   server2.createQueue(address, RoutingType.ANYCAST, address, null, true, false, -1, false, false);
   ServerLocator locator = createInVMNonHALocator();
   ClientSessionFactory csf = createSessionFactory(locator);
   ClientSession session = csf.createSession();
   ClientProducer producer = session.createProducer(address);
   for (int i = 0; i < 100; i++) {
      ClientMessage message = session.createMessage(true);
      message.getBodyBuffer().writeString("m" + i);
      producer.send(message);
   }

   ActiveMQServerControl managementControl = createManagementControl();
   handler.scaleDown(managementControl);
   locator.close();
   locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY, params)));
   csf = createSessionFactory(locator);
   session = csf.createSession();
   session.start();
   ClientConsumer consumer = session.createConsumer(address);
   for (int i = 0; i < 100; i++) {
      ClientMessage m = consumer.receive(5000);
      assertNotNull(m);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:38,代码来源:ActiveMQServerControlTest.java

示例6: testTotalConsumerCount

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testTotalConsumerCount() throws Exception {
   String random1 = RandomUtil.randomString();
   String random2 = RandomUtil.randomString();

   ActiveMQServerControl serverControl = createManagementControl();
   QueueControl queueControl1 = ManagementControlHelper.createQueueControl(SimpleString.toSimpleString(random1), SimpleString.toSimpleString(random1), RoutingType.ANYCAST, mbeanServer);
   QueueControl queueControl2 = ManagementControlHelper.createQueueControl(SimpleString.toSimpleString(random2), SimpleString.toSimpleString(random2), RoutingType.ANYCAST, mbeanServer);

   ServerLocator locator = createInVMNonHALocator();
   ClientSessionFactory csf = createSessionFactory(locator);
   ClientSession session = csf.createSession();

   session.createQueue(random1, RoutingType.ANYCAST, random1);
   session.createQueue(random2, RoutingType.ANYCAST, random2);

   ClientConsumer consumer1 = session.createConsumer(random1);
   ClientConsumer consumer2 = session.createConsumer(random2);

   assertEquals(usingCore() ? 3 : 2, serverControl.getTotalConsumerCount());
   assertEquals(1, queueControl1.getConsumerCount());
   assertEquals(1, queueControl2.getConsumerCount());

   consumer1.close();
   consumer2.close();

   session.deleteQueue(random1);
   session.deleteQueue(random2);

   session.close();

   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:ActiveMQServerControlTest.java

示例7: testSingleConnectorSingleServer

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testSingleConnectorSingleServer() throws Exception {
   ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
   ClientSessionFactory csf = createSessionFactory(locator);
   csf.close();
   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:ServerLocatorConnectTest.java

示例8: testStressConnection

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testStressConnection() throws Exception {

   for (int i = 0; i < 10; i++) {
      ServerLocator locatorSendx = createFactory(isNetty()).setReconnectAttempts(15);
      ClientSessionFactory factoryx = locatorSendx.createSessionFactory();
      factoryx.close();
      locatorSendx.close();
   }

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:ConsumerTest.java

示例9: main

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
   try {
      if (args.length != 1) {
         throw new Exception("require 1 argument: connector factory class name");
      }

      System.out.println("I'm here");
      String connectorFactoryClassName = args[0];

      String queueName = RandomUtil.randomString();
      String messageText = RandomUtil.randomString();

      ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorFactoryClassName)).setReconnectAttempts(1).setInitialConnectAttempts(1);
      try {
         ClientSessionFactory sf = locator.createSessionFactory();
         ClientSession session = sf.createSession(false, true, true);

         session.createQueue(queueName, queueName, null, false);
         ClientProducer producer = session.createProducer(queueName);
         ClientConsumer consumer = session.createConsumer(queueName);

         ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
         message.getBodyBuffer().writeString(messageText);
         producer.send(message);

         session.start();

         ClientMessage receivedMsg = consumer.receive(5000);
         if (receivedMsg == null) {
            throw new Exception("did not receive the message");
         }

         String text = receivedMsg.getBodyBuffer().readString();
         if (text == null || !text.equals(messageText)) {
            throw new Exception("received " + text + ", was expecting " + messageText);
         }

         // clean all resources to exit cleanly
         consumer.close();
         session.deleteQueue(queueName);
         session.close();
         sf.close();
         System.out.println("OK");
      } finally {
         locator.close();
      }
   } catch (Throwable t) {
      t.printStackTrace(System.out);

      String allStack = t.getMessage() + "|";
      StackTraceElement[] stackTrace = t.getStackTrace();
      for (StackTraceElement stackTraceElement : stackTrace) {
         allStack += stackTraceElement.toString() + "|";
      }
      // System.out.println(t.getClass().getName());
      // System.out.println(t.getMessage());
      System.out.println(allStack);
      System.exit(1);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:61,代码来源:SimpleClient.java

示例10: testDeleteTemporaryQueueWhenClientCrash

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testDeleteTemporaryQueueWhenClientCrash() throws Exception {
   session.close();
   sf.close();

   final SimpleString queue = RandomUtil.randomSimpleString();
   SimpleString address = RandomUtil.randomSimpleString();

   // server must received at least one ping from the client to pass
   // so that the server connection TTL is configured with the client value
   final CountDownLatch pingOnServerLatch = new CountDownLatch(1);
   server.getRemotingService().addIncomingInterceptor(new Interceptor() {

      @Override
      public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException {
         if (packet.getType() == PacketImpl.PING) {
            pingOnServerLatch.countDown();
         }
         return true;
      }
   });

   ServerLocator locator = createInVMNonHALocator();
   locator.setConnectionTTL(TemporaryQueueTest.CONNECTION_TTL);
   sf = addSessionFactory(createSessionFactory(locator));
   session = sf.createSession(false, true, true);

   session.createTemporaryQueue(address, queue);
   assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval(), TimeUnit.MILLISECONDS));
   assertEquals(1, server.getConnectionCount());

   RemotingConnection remotingConnection = server.getRemotingService().getConnections().iterator().next();
   final CountDownLatch serverCloseLatch = new CountDownLatch(1);
   remotingConnection.addCloseListener(new CloseListener() {
      @Override
      public void connectionClosed() {
         serverCloseLatch.countDown();
      }
   });

   ((ClientSessionInternal) session).getConnection().fail(new ActiveMQInternalErrorException("simulate a client failure"));

   // let some time for the server to clean the connections
   assertTrue("server has not closed the connection", serverCloseLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval() + 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));

   // The next getCount will be asynchronously done at the end of failure. We will wait some time until it has reached there.
   for (long timeout = System.currentTimeMillis() + 5000; timeout > System.currentTimeMillis() && server.getConnectionCount() > 0; ) {
      Thread.sleep(1);
   }

   assertEquals(0, server.getConnectionCount());

   session.close();

   sf.close();
   ServerLocator locator2 = createInVMNonHALocator();

   sf = addSessionFactory(createSessionFactory(locator2));
   session = sf.createSession(false, true, true);
   session.start();

   ActiveMQAction activeMQAction = new ActiveMQAction() {
      @Override
      public void run() throws ActiveMQException {
         session.createConsumer(queue);
      }
   };

   ActiveMQTestBase.expectActiveMQException("temp queue must not exist after the server detected the client crash", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, activeMQAction);

   session.close();

   locator2.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:75,代码来源:TemporaryQueueTest.java

示例11: testBody2

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testBody2() throws Exception {
   final String QUEUE_NAME = "A1";
   server = createServer(true);
   server.start();
   ServerLocator locator = createInVMNonHALocator();
   ClientSessionFactory factory = locator.createSessionFactory();
   ClientSession session = factory.createSession(false, true, true);

   session.createQueue(QUEUE_NAME, RoutingType.MULTICAST, QUEUE_NAME, true);

   ClientProducer producer = session.createProducer(QUEUE_NAME);

   ClientMessage msg = session.createMessage(true);
   byte[] bodyTst = new byte[10];
   for (int i = 0; i < 10; i++) {
      bodyTst[i] = (byte) (i + 1);
   }
   msg.getBodyBuffer().writeBytes(bodyTst);
   assertEquals(bodyTst.length, msg.getBodySize());
   producer.send(msg);

   session.close();
   locator.close();
   server.stop();

   ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
   XmlDataExporter xmlDataExporter = new XmlDataExporter();
   xmlDataExporter.process(xmlOutputStream, server.getConfiguration().getBindingsDirectory(), server.getConfiguration().getJournalDirectory(), server.getConfiguration().getPagingDirectory(), server.getConfiguration().getLargeMessagesDirectory());
   System.out.print(new String(xmlOutputStream.toByteArray()));

   clearDataRecreateServerDirs();
   server.start();
   checkForLongs();
   locator = createInVMNonHALocator();
   factory = locator.createSessionFactory();
   session = factory.createSession(false, false, true);
   ClientSession managementSession = factory.createSession(false, true, true);

   ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray());
   XmlDataImporter xmlDataImporter = new XmlDataImporter();
   xmlDataImporter.validate(xmlInputStream);
   xmlInputStream.reset();
   xmlDataImporter.process(xmlInputStream, session, managementSession);
   ClientConsumer consumer = session.createConsumer(QUEUE_NAME);
   session.start();

   msg = consumer.receive(CONSUMER_TIMEOUT);
   assertNotNull(msg);
   assertEquals(msg.getBodySize(), bodyTst.length);
   byte[] bodyRead = new byte[bodyTst.length];
   msg.getBodyBuffer().readBytes(bodyRead);
   assertEqualsByteArrays(bodyTst, bodyRead);

   session.close();
   locator.close();
   server.stop();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:59,代码来源:XmlImportExportTest.java

示例12: internalTest

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
private void internalTest(int MAX_MESSAGES,
                          String MY_ADDRESS,
                          String MY_QUEUE,
                          ActiveMQServer server) throws Exception {
   ServerLocator locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);

   ClientSessionFactory factory = createSessionFactory(locator);
   ClientSession session = factory.createSession(false, true, true);

   session.createQueue(MY_ADDRESS, MY_QUEUE, true);

   final ClientProducer producer = session.createProducer(MY_ADDRESS);

   final ClientMessage message = session.createMessage(false);
   message.getBodyBuffer().writeBytes(new byte[1024]);

   ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory());
   Callable<Object> sendMessageTask = new Callable<Object>() {
      @Override
      public Object call() throws ActiveMQException {
         producer.send(message);
         return null;
      }
   };

   int sendCount = 0;

   for (int i = 0; i < MAX_MESSAGES; i++) {
      Future<Object> future = executor.submit(sendMessageTask);
      try {
         future.get(3, TimeUnit.SECONDS);
         sendCount++;
      } catch (TimeoutException ex) {
         // message sending has been blocked
         break;
      } finally {
         future.cancel(true); // may or may not desire this
      }
   }

   executor.shutdown();
   session.close();

   session = factory.createSession(false, true, true);
   session.start();
   ClientConsumer consumer = session.createConsumer(MY_QUEUE);
   for (int i = 0; i < sendCount; i++) {
      ClientMessage msg = consumer.receive(250);
      if (msg == null)
         break;
      msg.acknowledge();
   }

   session.close();
   locator.close();
   server.stop();

   // Using the code only so the test doesn't fail just because someone edits the log text
   Assert.assertTrue("Expected to find AMQ222183", AssertionLoggerHandler.findText("AMQ222183", "myAddress"));
   Assert.assertTrue("Expected to find AMQ221046", AssertionLoggerHandler.findText("AMQ221046", "myAddress"));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:62,代码来源:AddressFullLoggingTest.java

示例13: runTest

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
private void runTest(final TestRunner runnable) throws Throwable {
   final int numIts = 1;

   try {
      for (int i = 0; i < numIts; i++) {
         AsynchronousFailoverTest.log.info("Iteration " + i);
         ServerLocator locator = getServerLocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setReconnectAttempts(15).setConfirmationWindowSize(10 * 1024 * 1024);
         sf = createSessionFactoryAndWaitForTopology(locator, 2);
         try {

            ClientSession createSession = sf.createSession(true, true);

            createSession.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, (SimpleString) null, true);

            RemotingConnection conn = ((ClientSessionInternal) createSession).getConnection();

            Thread t = new Thread(runnable);

            t.setName("MainTEST");

            t.start();

            long randomDelay = (long) (2000 * Math.random());

            AsynchronousFailoverTest.log.info("Sleeping " + randomDelay);

            Thread.sleep(randomDelay);

            AsynchronousFailoverTest.log.info("Failing asynchronously");

            // Simulate failure on connection
            synchronized (lockFail) {
               if (log.isDebugEnabled()) {
                  log.debug("#test crashing test");
               }
               crash(createSession);
            }

            /*if (listener != null)
            {
               boolean ok = listener.latch.await(10000, TimeUnit.MILLISECONDS);

               Assert.assertTrue(ok);
            }*/

            runnable.setFailed();

            AsynchronousFailoverTest.log.info("Fail complete");

            t.join(TimeUnit.SECONDS.toMillis(60));
            if (t.isAlive()) {
               System.out.println(threadDump("Thread still running from the test"));
               t.interrupt();
               fail("Test didn't complete successful, thread still running");
            }

            runnable.checkForExceptions();

            createSession.close();

            Assert.assertEquals(0, sf.numSessions());

            locator.close();
         } finally {
            locator.close();

            Assert.assertEquals(0, sf.numConnections());
         }

         if (i != numIts - 1) {
            tearDown();
            runnable.checkForExceptions();
            runnable.reset();
            setUp();
         }
      }
   } finally {
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:80,代码来源:AsynchronousFailoverTest.java

示例14: testListPreparedTransactionDetails

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Test
public void testListPreparedTransactionDetails() throws Exception {
   SimpleString atestq = new SimpleString("BasicXaTestq");
   Xid xid = newXID();

   ServerLocator locator = createInVMNonHALocator();
   ClientSessionFactory csf = createSessionFactory(locator);
   ClientSession clientSession = csf.createSession(true, false, false);
   clientSession.createQueue(atestq, atestq, null, true);

   ClientMessage m1 = createTextMessage(clientSession, "");
   ClientMessage m2 = createTextMessage(clientSession, "");
   ClientMessage m3 = createTextMessage(clientSession, "");
   ClientMessage m4 = createTextMessage(clientSession, "");
   m1.putStringProperty("m1", "m1");
   m2.putStringProperty("m2", "m2");
   m3.putStringProperty("m3", "m3");
   m4.putStringProperty("m4", "m4");
   ClientProducer clientProducer = clientSession.createProducer(atestq);
   clientSession.start(xid, XAResource.TMNOFLAGS);
   clientProducer.send(m1);
   clientProducer.send(m2);
   clientProducer.send(m3);
   clientProducer.send(m4);
   clientSession.end(xid, XAResource.TMSUCCESS);
   clientSession.prepare(xid);

   ActiveMQServerControl serverControl = createManagementControl();

   JsonArray jsonArray = JsonUtil.readJsonArray(serverControl.listProducersInfoAsJSON());

   assertEquals(1, jsonArray.size());
   assertEquals(4, ((JsonObject) jsonArray.get(0)).getInt("msgSent"));

   clientSession.close();
   locator.close();

   String txDetails = serverControl.listPreparedTransactionDetailsAsJSON();

   Assert.assertTrue(txDetails.matches(".*m1.*"));
   Assert.assertTrue(txDetails.matches(".*m2.*"));
   Assert.assertTrue(txDetails.matches(".*m3.*"));
   Assert.assertTrue(txDetails.matches(".*m4.*"));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:45,代码来源:ActiveMQServerControlTest.java

示例15: createQueue

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入方法依赖的package包/类
@Before
public void createQueue() throws Exception {

   ServerLocator locator = createFactory(isNetty());

   ClientSessionFactory sf = createSessionFactory(locator);

   ClientSessionFactory sf2 = createSessionFactory(locator);

   ClientSession session = sf.createSession(false, true, true, true);

   server.createQueue(QUEUE, RoutingType.ANYCAST, QUEUE, null, true, false);

   session.close();

   sf.close();

   locator.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:ConsumerTest.java


注:本文中的org.apache.activemq.artemis.api.core.client.ServerLocator.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。