org.apache.activemq.artemis.api.core.management.AcceptorControl

Here are the examples of the java api class org.apache.activemq.artemis.api.core.management.AcceptorControl taken from open source projects.

1. AcceptorControlTest#testAttributes()

Project: activemq-artemis
File: AcceptorControlTest.java
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testAttributes() throws Exception {
    TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
    ActiveMQServer service = createServer(false, config);
    service.setMBeanServer(mbeanServer);
    service.start();
    AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
    Assert.assertEquals(acceptorConfig.getName(), acceptorControl.getName());
    Assert.assertEquals(acceptorConfig.getFactoryClassName(), acceptorControl.getFactoryClassName());
}

2. AcceptorControlTest#testStartStop()

Project: activemq-artemis
File: AcceptorControlTest.java
@Test
public void testStartStop() throws Exception {
    TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
    ActiveMQServer service = createServer(false, config);
    service.setMBeanServer(mbeanServer);
    service.start();
    AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
    // started by the server
    Assert.assertTrue(acceptorControl.isStarted());
    ServerLocator locator = createInVMNonHALocator();
    ClientSessionFactory sf = createSessionFactory(locator);
    ClientSession session = sf.createSession(false, true, true);
    Assert.assertNotNull(session);
    session.close();
    acceptorControl.stop();
    Assert.assertFalse(acceptorControl.isStarted());
    try {
        sf.createSession(false, true, true);
        Assert.fail("acceptor must not accept connections when stopped accepting");
    } catch (ActiveMQException e) {
    }
    acceptorControl.start();
    Assert.assertTrue(acceptorControl.isStarted());
    locator = createInVMNonHALocator();
    sf = createSessionFactory(locator);
    session = sf.createSession(false, true, true);
    Assert.assertNotNull(session);
    session.close();
    acceptorControl.stop();
    Assert.assertFalse(acceptorControl.isStarted());
    try {
        sf.createSession(false, true, true);
        Assert.fail("acceptor must not accept connections when stopped accepting");
    } catch (ActiveMQException e) {
    }
}

3. AcceptorControlTest#testNotifications()

Project: activemq-artemis
File: AcceptorControlTest.java
@Test
public void testNotifications() throws Exception {
    TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
    Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig);
    ActiveMQServer service = createServer(false, config);
    service.setMBeanServer(mbeanServer);
    service.start();
    AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
    SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
    service.getManagementService().addNotificationListener(notifListener);
    Assert.assertEquals(0, notifListener.getNotifications().size());
    acceptorControl.stop();
    Assert.assertEquals(1, notifListener.getNotifications().size());
    Notification notif = notifListener.getNotifications().get(0);
    Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType());
    Assert.assertEquals(InVMAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
    acceptorControl.start();
    Assert.assertEquals(2, notifListener.getNotifications().size());
    notif = notifListener.getNotifications().get(1);
    Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType());
    Assert.assertEquals(InVMAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
}

4. ManagementServiceImpl#registerAcceptor()

Project: activemq-artemis
File: ManagementServiceImpl.java
@Override
public synchronized void registerAcceptor(final Acceptor acceptor, final TransportConfiguration configuration) throws Exception {
    ObjectName objectName = objectNameBuilder.getAcceptorObjectName(configuration.getName());
    AcceptorControl control = new AcceptorControlImpl(acceptor, storageManager, configuration);
    registerInJMX(objectName, control);
    registerInRegistry(ResourceNames.CORE_ACCEPTOR + configuration.getName(), control);
}