Java Code Examples for org.apache.activemq.broker.TransportConnector#stop()

The following examples show how to use org.apache.activemq.broker.TransportConnector#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMSBroker.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Stopping ActiveMQ embedded broker
 *
 * @return true if broker is successfully stopped
 */
public boolean stop() {
    try {
        log.info(" ************* Stopping **************");
        if (broker.isStarted()) {
            broker.stop();
            for (TransportConnector transportConnector : transportConnectors) {
                transportConnector.stop();
            }
            setBrokerStatus(false);
        }
        return true;
    } catch (Exception e) {
        log.error("Error while shutting down the broker", e);
        return false;
    }
}
 
Example 2
Source File: JMSBroker.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Stopping ActiveMQ embedded broker
 *
 * @return true if broker is successfully stopped
 */
public boolean stop() {
    try {
        log.info(" ************* Stopping **************");
        if (broker.isStarted()) {
            broker.stop();
            for (TransportConnector transportConnector : transportConnectors) {
                transportConnector.stop();
            }
            setBrokerStatus(false);
        }
        return true;
    } catch (Exception e) {
        log.error("Error while shutting down the broker", e);
        return false;
    }
}
 
Example 3
Source File: JMSEndpointSuspensionViaVFSTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private boolean stopBroker() {
    try {
        log.info(" ************* Stopping **************");
        if (broker.isStarted()) {
            broker.stop();
            for (TransportConnector transportConnector : getTCPConnectors()) {
                transportConnector.stop();
            }
        }
        return true;
    } catch (Exception e) {
        log.error("Error while shutting down the broker", e);
        return false;
    }
}
 
Example 4
Source File: JMSEndpointSuspensionViaVFSTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private boolean stopBroker() {
    try {
        log.info(" ************* Stopping **************");
        if (broker.isStarted()) {
            broker.stop();
            for(TransportConnector transportConnector : getTCPConnectors()) {
                transportConnector.stop();
            }
        }
        return true;
    } catch (Exception e) {
        log.error("Error while shutting down the broker", e);
        return false;
    }
}
 
Example 5
Source File: OpenEjbBrokerFactoryTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void stopBroker(final BrokerService broker) throws Exception {
    if (broker == null) return;

    if (broker.getJmsBridgeConnectors() != null) {
        for (final JmsConnector connector : broker.getJmsBridgeConnectors()) {
            connector.stop();
        }
    }
    for (final Object o : broker.getTransportConnectors()) {
        final TransportConnector tc = (TransportConnector) o;
        tc.stop();

    }
    broker.stop();
}
 
Example 6
Source File: DiscoveryTransportBrokerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public void testPublisherFailsOver() throws Exception {
   ActiveMQDestination destination = new ActiveMQQueue("TEST");
   int deliveryMode = DeliveryMode.NON_PERSISTENT;

   // Start a normal consumer on the local broker
   StubConnection connection1 = createConnection();
   ConnectionInfo connectionInfo1 = createConnectionInfo();
   SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
   ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
   connection1.send(connectionInfo1);
   connection1.send(sessionInfo1);
   connection1.request(consumerInfo1);

   // Start a normal consumer on a remote broker
   StubConnection connection2 = createRemoteConnection();
   ConnectionInfo connectionInfo2 = createConnectionInfo();
   SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
   ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
   connection2.send(connectionInfo2);
   connection2.send(sessionInfo2);
   connection2.request(consumerInfo2);

   // Start a failover publisher.
   StubConnection connection3 = createFailoverConnection();
   ConnectionInfo connectionInfo3 = createConnectionInfo();
   SessionInfo sessionInfo3 = createSessionInfo(connectionInfo3);
   ProducerInfo producerInfo3 = createProducerInfo(sessionInfo3);
   connection3.send(connectionInfo3);
   connection3.send(sessionInfo3);
   connection3.send(producerInfo3);

   // Send the message using the fail over publisher.
   connection3.request(createMessage(producerInfo3, destination, deliveryMode));

   // The message will be sent to one of the brokers.
   FailoverTransport ft = connection3.getTransport().narrow(FailoverTransport.class);

   // See which broker we were connected to.
   StubConnection connectionA;
   StubConnection connectionB;
   TransportConnector serverA;
   if (connector.getServer().getConnectURI().getPort() == ft.getConnectedTransportURI().getPort()) {
      connectionA = connection1;
      connectionB = connection2;
      serverA = connector;
   } else {
      connectionA = connection2;
      connectionB = connection1;
      serverA = remoteConnector;
   }

   assertNotNull(receiveMessage(connectionA));
   assertNoMessagesLeft(connectionB);

   // Dispose the server so that it fails over to the other server.
   LOG.info("Disconnecting active server");
   serverA.stop();

   LOG.info("Sending request that should failover");
   connection3.request(createMessage(producerInfo3, destination, deliveryMode));

   assertNotNull(receiveMessage(connectionB));
   assertNoMessagesLeft(connectionA);

}