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


Java ServerLocator类代码示例

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


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

示例1: releaseFactoryOnCreateSessionException

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void releaseFactoryOnCreateSessionException() throws Exception {
    ServerLocator locator = mock(ServerLocator.class);
    ClientSessionFactory factory = mock(ClientSessionFactory.class);
    when(locator.createSessionFactory()).thenReturn(factory);

    String exceptionMessage = "***";
    try {
        new ServerConnector(locator, csf -> {
            throw new IOException(exceptionMessage);
        });
        fail("should've let the create session exception bubble up!");
    } catch (IOException e) {
        assertThat(e.getMessage(), is(exceptionMessage));
    }
    verify(factory).close();
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:ServerConnectorTest.java

示例2: createEmbeddedConnectionFactory

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(
		Class<T> factoryClass) throws Exception {
	try {
		TransportConfiguration transportConfiguration = new TransportConfiguration(
				InVMConnectorFactory.class.getName(),
				this.properties.getEmbedded().generateTransportParameters());
		ServerLocator serviceLocator = ActiveMQClient
				.createServerLocatorWithoutHA(transportConfiguration);
		return factoryClass.getConstructor(ServerLocator.class)
				.newInstance(serviceLocator);
	}
	catch (NoClassDefFoundError ex) {
		throw new IllegalStateException("Unable to create InVM "
				+ "Artemis connection, ensure that artemis-jms-server.jar "
				+ "is in the classpath", ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:ArtemisConnectionFactoryFactory.java

示例3: setUp

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

   server = createServer(false);

   server.start();
   ServerLocator locator = createInVMNonHALocator();

   ClientSessionFactory sf = createSessionFactory(locator);

   session = sf.createSession();

   session.start();
   session.createQueue("foo", RoutingType.ANYCAST, "foo");

   producer = session.createProducer("foo");
   consumer = session.createConsumer("foo", "animal='giraffe'");
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:ConsumerFilterTest.java

示例4: testDuplicate

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
public void testDuplicate() throws Exception {
   ActiveMQDestination queue = (ActiveMQDestination) session.createQueue("TEST,TEST");
   for (int i = 0; i < data.length; i++) {
      Message message = createMessage(i);
      configureMessage(message);
      if (verbose) {
         LOG.info("About to send a message: " + message + " with text: " + data[i]);
      }
      producer.send(queue, message);
   }

   Thread.sleep(200); // wait for messages to be queue;

   try (ServerLocator locator = ServerLocatorImpl.newLocator("tcp://localhost:61616");
        ClientSessionFactory factory = locator.createSessionFactory();
        ClientSession session = factory.createSession()) {
      ClientSession.QueueQuery query = session.queueQuery(new SimpleString("TEST"));
      assertNotNull(query);
      assertEquals(data.length, query.getMessageCount());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:JmsQueueCompositeSendReceiveTest.java

示例5: testAutClose

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void testAutClose() throws Exception {
   ServerLocator locatorx;
   ClientSession sessionx;
   ClientSessionFactory factoryx;
   try (ServerLocator locator = createInVMNonHALocator();
        ClientSessionFactory factory = locator.createSessionFactory();
        ClientSession session = factory.createSession(false, false)) {
      locatorx = locator;
      sessionx = session;
      factoryx = factory;
   }

   assertTrue(locatorx.isClosed());
   assertTrue(sessionx.isClosed());
   assertTrue(factoryx.isClosed());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:AutoCloseCoreTest.java

示例6: testStompProtocolManagerLeak

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
@BMRules(
   rules = {@BMRule(
      name = "StompProtocolManager Leak Server Rule",
      targetClass = "org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManager",
      targetMethod = "onNotification(org.apache.activemq.artemis.core.server.management.Notification)",
      targetLocation = "EXIT",
      helper = "org.apache.activemq.artemis.tests.extras.byteman.StompInternalStateTest",
      action = "verifyBindingAddRemove($1, $0.destinations)")})
public void testStompProtocolManagerLeak() throws Exception {
   ClientSession session = null;
   try {
      assertNull(resultTestStompProtocolManagerLeak);
      ServerLocator locator = createNettyNonHALocator();
      ClientSessionFactory factory = createSessionFactory(locator);
      session = factory.createSession();
      session.createTemporaryQueue(STOMP_QUEUE_NAME, STOMP_QUEUE_NAME);
      session.deleteQueue(STOMP_QUEUE_NAME);

      assertNull(resultTestStompProtocolManagerLeak);
   } finally {
      if (session != null) {
         session.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:StompInternalStateTest.java

示例7: createSessionFactoryAndWaitForTopology

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
protected ClientSessionFactoryInternal createSessionFactoryAndWaitForTopology(ServerLocator locator,
                                                                              int topologyMembers,
                                                                              ActiveMQServer server) throws Exception {
   ClientSessionFactoryInternal sf;
   CountDownLatch countDownLatch = new CountDownLatch(topologyMembers);

   FailoverTestBase.LatchClusterTopologyListener topListener = new FailoverTestBase.LatchClusterTopologyListener(countDownLatch);
   locator.addClusterTopologyListener(topListener);

   sf = (ClientSessionFactoryInternal) locator.createSessionFactory();
   addSessionFactory(sf);

   boolean ok = countDownLatch.await(5, TimeUnit.SECONDS);
   locator.removeClusterTopologyListener(topListener);
   if (!ok) {
      if (server != null) {
         log.info("failed topology, Topology on server = " + server.getClusterManager().describe());
      }
   }
   Assert.assertTrue("expected " + topologyMembers + " members", ok);
   return sf;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:MultipleBackupsFailoverTestBase.java

示例8: testThreadPoolInjection

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

   ServerLocator serverLocator = new ServerLocatorImpl(false);

   ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, 1, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
   ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(1);
   serverLocator.setThreadPools(threadPool, scheduledThreadPool);

   Field threadPoolField = ServerLocatorImpl.class.getDeclaredField("threadPool");
   Field scheduledThreadPoolField = ServerLocatorImpl.class.getDeclaredField("scheduledThreadPool");

   Method initialise = ServerLocatorImpl.class.getDeclaredMethod("initialise");
   initialise.setAccessible(true);
   initialise.invoke(serverLocator);

   threadPoolField.setAccessible(true);
   scheduledThreadPoolField.setAccessible(true);

   ThreadPoolExecutor tpe = (ThreadPoolExecutor) threadPoolField.get(serverLocator);
   ScheduledThreadPoolExecutor stpe = (ScheduledThreadPoolExecutor) scheduledThreadPoolField.get(serverLocator);

   assertEquals(threadPool, tpe);
   assertEquals(scheduledThreadPool, stpe);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:ClientThreadPoolsTest.java

示例9: testTwoWaySSLVerifyClientHostNegative

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void testTwoWaySSLVerifyClientHostNegative() throws Exception {
   NettyAcceptor acceptor = (NettyAcceptor) server.getRemotingService().getAcceptor("nettySSL");
   acceptor.getConfiguration().put(TransportConstants.VERIFY_HOST_PROP_NAME, true);
   server.getRemotingService().stop(false);
   server.getRemotingService().start();
   server.getRemotingService().startAcceptors();

   tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, storeType);
   tc.getParams().put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, storeType);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, CLIENT_SIDE_TRUSTSTORE);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, PASSWORD);
   tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, CLIENT_SIDE_KEYSTORE);
   tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, PASSWORD);

   server.getRemotingService().addIncomingInterceptor(new MyInterceptor());

   ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
   try {
      ClientSessionFactory sf = createSessionFactory(locator);
      fail("Creating a session here should fail due to a certificate with a CN that doesn't match the host name.");
   } catch (Exception e) {
      // ignore
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:CoreClientOverTwoWaySSLTest.java

示例10: testTwoWaySSLVerifyClientTrustAllTrue

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void testTwoWaySSLVerifyClientTrustAllTrue() throws Exception {
   NettyAcceptor acceptor = (NettyAcceptor) server.getRemotingService().getAcceptor("nettySSL");
   acceptor.getConfiguration().put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true);
   server.getRemotingService().stop(false);
   server.getRemotingService().start();
   server.getRemotingService().startAcceptors();

   //Set trust all so this should work even with no trust store set
   tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
   tc.getParams().put(TransportConstants.TRUST_ALL_PROP_NAME, true);
   tc.getParams().put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, storeType);
   tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, CLIENT_SIDE_KEYSTORE);
   tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, PASSWORD);

   server.getRemotingService().addIncomingInterceptor(new MyInterceptor());

   ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
   ClientSessionFactory sf = createSessionFactory(locator);
   sf.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:CoreClientOverTwoWaySSLTest.java

示例11: testOneWaySSLUsingDefaultSslContext

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

   tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
   tc.getParams().put(TransportConstants.USE_DEFAULT_SSL_CONTEXT_PROP_NAME, true);

   SSLContext.setDefault(SSLSupport.createContext(TransportConstants.DEFAULT_KEYSTORE_PROVIDER, TransportConstants.DEFAULT_KEYSTORE_PATH, TransportConstants.DEFAULT_KEYSTORE_PASSWORD, storeType, CLIENT_SIDE_TRUSTSTORE, PASSWORD));

   ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
   ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
   ClientSession session = addClientSession(sf.createSession(false, true, true));
   session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false);
   ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE));

   ClientMessage message = createTextMessage(session, text);
   producer.send(message);

   ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE));
   session.start();

   ClientMessage m = consumer.receive(1000);
   Assert.assertNotNull(m);
   Assert.assertEquals(text, m.getBodyBuffer().readString());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:CoreClientOverOneWaySSLTest.java

示例12: testSetInvalidSendACK

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

   locator.setConfirmationWindowSize(-1);

   ClientSessionFactory csf = createSessionFactory(locator);
   ClientSession session = csf.createSession(null, null, false, true, true, false, 1);

   boolean failed = false;
   try {
      session.setSendAcknowledgementHandler(new SendAcknowledgementHandler() {
         @Override
         public void sendAcknowledged(Message message) {
         }
      });
   } catch (Throwable expected) {
      failed = true;
   }

   assertTrue("Expected a failure on setting ACK Handler", failed);

   session.createQueue(address, queueName, false);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:SessionSendAcknowledgementHandlerTest.java

示例13: testOneWaySSLWithBadClientCipherSuite

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void testOneWaySSLWithBadClientCipherSuite() throws Exception {
   createCustomSslServer();
   tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, storeType);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, CLIENT_SIDE_TRUSTSTORE);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, PASSWORD);
   tc.getParams().put(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME, "myBadCipherSuite");

   ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
   try {
      createSessionFactory(locator);
      Assert.fail();
   } catch (ActiveMQNotConnectedException e) {
      Assert.assertTrue(true);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:CoreClientOverOneWaySSLTest.java

示例14: isActive

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
/**
 * In a cluster of replicated live/backup pairs if a backup crashes and then its live crashes the cluster will
 * retain the topology information of the live such that when the live server restarts it will check the
 * cluster to see if its nodeID is present (which it will be) and then it will activate as a backup rather than
 * a live. To prevent this situation an additional check is necessary to see if the server with the matching
 * nodeID is actually active or not which is done by attempting to make a connection to it.
 *
 * @param transportConfiguration
 * @return
 */
private boolean isActive(TransportConfiguration transportConfiguration) {
   boolean result = false;

   try (ServerLocator serverLocator = ActiveMQClient.createServerLocator(false, transportConfiguration);
        ClientSessionFactory clientSessionFactory = serverLocator.createSessionFactory();
        ClientSession clientSession = clientSessionFactory.createSession(user, password, false, false, false, false, 0)) {
      result = true;
   } catch (Exception e) {
      if (logger.isDebugEnabled()) {
         logger.debug("isActive check failed", e);
      }
   }

   return result;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SharedNothingLiveActivation.java

示例15: testOneWaySSLWithMismatchedCipherSuites

import org.apache.activemq.artemis.api.core.client.ServerLocator; //导入依赖的package包/类
@Test
public void testOneWaySSLWithMismatchedCipherSuites() throws Exception {
   createCustomSslServer(getEnabledCipherSuites()[0], "TLSv1.2");
   tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, storeType);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, CLIENT_SIDE_TRUSTSTORE);
   tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, PASSWORD);
   tc.getParams().put(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME, getEnabledCipherSuites()[1]);
   tc.getParams().put(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME, "TLSv1.2");

   ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
   try {
      createSessionFactory(locator);
      Assert.fail();
   } catch (ActiveMQNotConnectedException e) {
      Assert.assertTrue(true);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:CoreClientOverOneWaySSLTest.java


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