Here are the examples of the java api class org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor taken from open source projects.
1. NettyAcceptorTest#testStartStop()
Project: activemq-artemis
File: NettyAcceptorTest.java
File: NettyAcceptorTest.java
@Test public void testStartStop() throws Exception { BufferHandler handler = new BufferHandler() { @Override public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) { } }; Map<String, Object> params = new HashMap<>(); ServerConnectionLifeCycleListener listener = new ServerConnectionLifeCycleListener() { @Override public void connectionException(final Object connectionID, final ActiveMQException me) { } @Override public void connectionDestroyed(final Object connectionID) { } @Override public void connectionCreated(final ActiveMQComponent component, final Connection connection, final ProtocolManager protocol) { } @Override public void connectionReadyForWrites(Object connectionID, boolean ready) { } }; pool2 = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory()); NettyAcceptor acceptor = new NettyAcceptor("netty", null, params, handler, listener, pool2, null); addActiveMQComponent(acceptor); acceptor.start(); Assert.assertTrue(acceptor.isStarted()); acceptor.stop(); Assert.assertFalse(acceptor.isStarted()); ActiveMQTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); acceptor.start(); Assert.assertTrue(acceptor.isStarted()); acceptor.stop(); Assert.assertFalse(acceptor.isStarted()); ActiveMQTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); pool2.shutdown(); pool2.awaitTermination(1, TimeUnit.SECONDS); }
2. CoreClientOverOneWaySSLTest#testOneWaySSLReloaded()
Project: activemq-artemis
File: CoreClientOverOneWaySSLTest.java
File: CoreClientOverOneWaySSLTest.java
@Test public void testOneWaySSLReloaded() throws Exception { createCustomSslServer(); server.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, null, false, false); String text = RandomUtil.randomString(); // create a valid SSL connection and keep it for use later 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); ServerLocator existingLocator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); existingLocator.setCallTimeout(3000); ClientSessionFactory existingSessionFactory = addSessionFactory(createSessionFactory(existingLocator)); ClientSession existingSession = addClientSession(existingSessionFactory.createSession(false, true, true)); ClientConsumer existingConsumer = addClientConsumer(existingSession.createConsumer(CoreClientOverOneWaySSLTest.QUEUE)); // create an invalid SSL connection 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, "other-client-side-truststore." + storeType.toLowerCase()); tc.getParams().put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, PASSWORD); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)).setCallTimeout(3000); try { addSessionFactory(createSessionFactory(locator)); fail("Creating session here should fail due to SSL handshake problems."); } catch (Exception e) { } // reload the acceptor to reload the SSL stores NettyAcceptor acceptor = (NettyAcceptor) server.getRemotingService().getAcceptor("nettySSL"); acceptor.setKeyStorePath("other-server-side-keystore." + storeType.toLowerCase()); acceptor.reload(); // create a session with the locator which failed previously proving that the SSL stores have been reloaded ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession session = addClientSession(sf.createSession(false, true, true)); ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE)); ClientMessage message = createTextMessage(session, text); producer.send(message); producer.send(message); ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE)); session.start(); Message m = consumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); consumer.close(); // use the existing connection to prove it wasn't lost when the acceptor was reloaded existingSession.start(); m = existingConsumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); }