org.apache.activemq.ActiveMQConnectionFactory - java examples

Here are the examples of the java api org.apache.activemq.ActiveMQConnectionFactory taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

18 View Complete Implementation : NIOSSLLoadTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected void setUp() throws Exception {
    System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
    System.setProperty("javax.net.ssl.trustStorePreplacedword", PreplacedWORD);
    System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
    System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStorePreplacedword", PreplacedWORD);
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.setUseJmx(false);
    TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
    broker.start();
    broker.waitUntilStarted();
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
    connection = factory.createConnection();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    connection.start();
}

18 View Complete Implementation : BrokerXmlConfigTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    // START SNIPPET: bean
    // configure the connection factory using
    // normal Java Bean property methods
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    // configure the embedded broker using an XML config file
    // which is either a URL or a resource on the clreplacedpath
    // TODO ...
    // connectionFactory.setBrokerXmlConfig("file:src/sample-conf/default.xml");
    // you only need to configure the broker URL if you wish to change the
    // default connection mechanism, which in this test case we do
    connectionFactory.setBrokerURL("vm://localhost");
    // END SNIPPET: bean
    return connectionFactory;
}

18 View Complete Implementation : TwoBrokerTopicSendReceiveUsingTcpTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ActiveMQConnectionFactory createSenderConnectionFactory() throws JMSException {
    try {
        ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(senderBroker.getTransportConnectors().get(0).getConnectUri());
        return fac;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

18 View Complete Implementation : NetworkRestartTest.java
Copyright Apache License 2.0
Author : apache
protected void doSetUp() throws Exception {
    remoteBroker = createRemoteBroker();
    remoteBroker.start();
    remoteBroker.waitUntilStarted();
    localBroker = createLocalBroker();
    localBroker.start();
    localBroker.waitUntilStarted();
    String localURI = "tcp://localhost:61616";
    String remoteURI = "tcp://localhost:61617";
    ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
    localConnection = fac.createConnection();
    localConnection.setClientID("local");
    localConnection.start();
    fac = new ActiveMQConnectionFactory(remoteURI);
    fac.sereplacedchTopicAdvisories(false);
    remoteConnection = fac.createConnection();
    remoteConnection.setClientID("remote");
    remoteConnection.start();
    localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

18 View Complete Implementation : TopicSubscriptionZeroPrefetchTest.java
Copyright Apache License 2.0
Author : apache
@Before
public void setUp() throws Exception {
    brokerService = createBroker();
    ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("vm://localhost");
    activeMQConnectionFactory.sereplacedchTopicAdvisories(true);
    connection = activeMQConnectionFactory.createConnection();
    connection.setClientID("ClientID-1");
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    destination = new ActiveMQTopic(TOPIC_NAME);
    producer = session.createProducer(destination);
    connection.start();
}

18 View Complete Implementation : NIOSSLConcurrencyTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected void setUp() throws Exception {
    System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
    System.setProperty("javax.net.ssl.trustStorePreplacedword", PreplacedWORD);
    System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
    System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStorePreplacedword", PreplacedWORD);
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.setUseJmx(false);
    TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
    broker.start();
    broker.waitUntilStarted();
    failed = false;
    messageData = new byte[MESSAGE_SIZE];
    for (int i = 0; i < MESSAGE_SIZE; i++) {
        messageData[i] = (byte) (i & 0xff);
    }
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
    connection = factory.createConnection();
    for (int i = 0; i < PRODUCER_COUNT; i++) {
        producerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
    for (int i = 0; i < CONSUMER_COUNT; i++) {
        consumerSessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
    connection.start();
}

18 View Complete Implementation : FailoverBackupLeakTest.java
Copyright Apache License 2.0
Author : apache
private void check(String connectionProperties) throws Exception {
    String s1URL = newURI(0), s2URL = newURI(1);
    String uri = "failover://(" + s1URL + "," + s2URL + ")?" + connectionProperties;
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(uri);
    final int initCount1 = getConnectionCount(s1);
    final int initCount2 = getConnectionCount(s2);
    for (int i = 0; i < 10; i++) {
        buildConnection(factory);
    }
    replacedertTrue(connectionProperties + " broker1 connection count not zero: was[" + getConnectionCount(s1) + "]", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return getConnectionCount(s1) == initCount1;
        }
    }));
    replacedertTrue(connectionProperties + " broker2 connection count not zero: was[" + getConnectionCount(s2) + "]", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return getConnectionCount(s2) == initCount2;
        }
    }));
}

17 View Complete Implementation : FailoverStaticNetworkTest.java
Copyright Apache License 2.0
Author : apache
protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
    String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setDispatchAsync(false);
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setOptimizeAcknowledge(false);
    connectionFactory.setAlwaysSyncSend(true);
    return connectionFactory;
}

17 View Complete Implementation : DiscoveryTransportNoBrokerTest.java
Copyright Apache License 2.0
Author : apache
public void testMaxReconnectAttempts() throws JMSException {
    try {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://doesNOTexist)");
        LOG.info("Connecting.");
        Connection connection = factory.createConnection();
        connection.setClientID("test");
        fail("Did not fail to connect as expected.");
    } catch (JMSException expected) {
        replacedertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException);
    }
}

17 View Complete Implementation : MessageGroupLateArrivalsTest.java
Copyright Apache License 2.0
Author : apache
@Before
public void setUp() throws Exception {
    broker = createBroker();
    broker.start();
    ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory(connector.getConnectUri() + "?jms.prefetchPolicy.all=1000");
    connection = connFactory.createConnection();
    session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    destination = new ActiveMQQueue("test-queue2");
    producer = session.createProducer(destination);
    connection.start();
}

17 View Complete Implementation : QueueSubscriptionTest.java
Copyright Apache License 2.0
Author : apache
public void doMultipleClientsTest() throws Exception {
    // Create destination
    final ActiveMQDestination dest = createDestination();
    // Create consumers
    ActiveMQConnectionFactory consumerFactory = (ActiveMQConnectionFactory) createConnectionFactory();
    consumerFactory.getPrefetchPolicy().setAll(prefetchCount);
    startConsumers(consumerFactory, dest);
    startProducers(dest, messageCount);
    // Wait for messages to be received. Make it proportional to the
    // messages delivered.
    int totalMessageCount = messageCount * producerCount;
    if (dest.isTopic()) {
        totalMessageCount *= consumerCount;
    }
    waitForAllMessagesToBeReceived(totalMessageCount);
}

17 View Complete Implementation : MessageGroupDelayedTest.java
Copyright Apache License 2.0
Author : apache
@Override
public void setUp() throws Exception {
    broker = createBroker();
    broker.start();
    ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory(connector.getConnectUri() + "?jms.prefetchPolicy.all=1");
    connection = connFactory.createConnection();
    session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    destination = new ActiveMQQueue("test-queue2");
    producer = session.createProducer(destination);
    connection.start();
}

17 View Complete Implementation : CompositeMessageCursorUsageTest.java
Copyright Apache License 2.0
Author : apache
public void testCompositeMessageUsage() throws Exception {
    String compositeQueue = "compositeA,compositeB";
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
    JmsTemplate jt = new JmsTemplate(cf);
    jt.send(compositeQueue, new MessageCreator() {

        @Override
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage();
            tm.setText("test");
            return tm;
        }
    });
    jt.send("noCompositeA", new MessageCreator() {

        @Override
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage();
            tm.setText("test");
            return tm;
        }
    });
    jt.send("noCompositeB", new MessageCreator() {

        @Override
        public Message createMessage(Session session) throws JMSException {
            TextMessage tm = session.createTextMessage();
            tm.setText("test");
            return tm;
        }
    });
    replacedertEquals("Cursor memory usage wrong for 'noCompositeA' queue", 1032, getQueueView("noCompositeA").getCursorMemoryUsage());
    replacedertEquals("Cursor memory usage wrong for 'noCompositeB' queue", 1032, getQueueView("noCompositeB").getCursorMemoryUsage());
    replacedertEquals("Cursor memory usage wrong for 'CompositeA' queue", 1032, getQueueView("compositeA").getCursorMemoryUsage());
    replacedertEquals("Cursor memory usage wrong for 'CompositeB' queue", 1032, getQueueView("compositeB").getCursorMemoryUsage());
}

17 View Complete Implementation : DiscoveryTransportNoBrokerTest.java
Copyright Apache License 2.0
Author : apache
public void testInitialConnectDelayWithNoBroker() throws Exception {
    // the initialReconnectDelay only kicks in once a set of connect URL have
    // been returned from the discovery agent.
    // Up to that point the reconnectDelay is used which has a default value of 10
    // 
    long initialReconnectDelay = 4000;
    long startT = System.currentTimeMillis();
    String groupId = "WillNotMatch" + startT;
    try {
        String urlStr = "discovery:(multicast://default?group=" + groupId + ")?useExponentialBackOff=false&maxReconnectAttempts=2&reconnectDelay=" + initialReconnectDelay;
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlStr);
        LOG.info("Connecting.");
        Connection connection = factory.createConnection();
        connection.setClientID("test");
        fail("Did not fail to connect as expected.");
    } catch (JMSException expected) {
        replacedertTrue("reason is java.io.IOException, was: " + expected.getCause(), expected.getCause() instanceof java.io.IOException);
        long duration = System.currentTimeMillis() - startT;
        replacedertTrue("took at least initialReconnectDelay time: " + duration + " e:" + expected, duration >= initialReconnectDelay);
    }
}

16 View Complete Implementation : FailoverTransactionTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testFailoverProducerCloseBeforeTransaction() throws Exception {
    LOG.info(this + " running test testFailoverProducerCloseBeforeTransaction");
    startCleanBroker();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
    configureConnectionFactory(cf);
    Connection connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
    Queue destination = session.createQueue(QUEUE_NAME);
    MessageConsumer consumer = session.createConsumer(destination);
    produceMessage(session, destination);
    // restart to force failover and connection state recovery before the commit
    broker.stop();
    startBroker();
    session.commit();
    replacedert.replacedertNotNull("we got the message", consumer.receive(20000));
    session.commit();
    connection.close();
}

16 View Complete Implementation : NetworkLoadTest.java
Copyright Apache License 2.0
Author : apache
protected Connection createConnection(int brokerId) throws JMSException {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:" + (60000 + brokerId));
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setUseCompression(false);
    connectionFactory.setDispatchAsync(true);
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setOptimizeAcknowledge(false);
    connectionFactory.sereplacedchTopicAdvisories(false);
    ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
    qPrefetchPolicy.setQueuePrefetch(100);
    qPrefetchPolicy.setTopicPrefetch(1000);
    connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
    connectionFactory.setAlwaysSyncSend(true);
    return connectionFactory.createConnection();
}

16 View Complete Implementation : StartAndStopBrokerTest.java
Copyright Apache License 2.0
Author : apache
public void testStartupShutdown() throws Exception {
    // This systemproperty is used if we dont want to
    // have persistence messages as a default
    System.setProperty("activemq.persistenceAdapter", "org.apache.activemq.store.vm.VMPersistenceAdapter");
    // configuration of container and all protocols
    BrokerService broker = createBroker();
    // start a client
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:9100");
    factory.createConnection();
    // stop activemq broker
    broker.stop();
    // start activemq broker again
    broker = createBroker();
    // start a client again
    factory = new ActiveMQConnectionFactory("tcp://localhost:9100");
    factory.createConnection();
    // stop activemq broker
    broker.stop();
}

16 View Complete Implementation : RequestReplyTempDestRemovalAdvisoryRaceTest.java
Copyright Apache License 2.0
Author : apache
private void noConsumerAdvisory() throws JMSException {
    for (BrokerItem item : brokers.values()) {
        ActiveMQConnectionFactory brokerAFactory = new ActiveMQConnectionFactory(item.broker.getTransportConnectorByScheme("tcp").getName() + "?jms.watchTopicAdvisories=false");
        Connection connection = brokerAFactory.createConnection();
        connection.start();
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(AdvisorySupport.getNoTopicConsumersAdvisoryTopic(new ActiveMQTempTopic(">"))).setMessageListener(new MessageListener() {

            @Override
            public void onMessage(Message message) {
                sendsWithNoConsumers.incrementAndGet();
            }
        });
    }
}

16 View Complete Implementation : NetworkFailoverTest.java
Copyright Apache License 2.0
Author : apache
protected void doSetUp(boolean deleteAllMessages) throws Exception {
    remoteBroker = createRemoteBroker();
    remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    remoteBroker.setCacheTempDestinations(true);
    remoteBroker.start();
    localBroker = createLocalBroker();
    localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    localBroker.setCacheTempDestinations(true);
    localBroker.start();
    String localURI = "tcp://localhost:61616";
    String remoteURI = "tcp://localhost:61617";
    ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory("failover:(" + localURI + "," + remoteURI + ")?randomize=false&backup=false&trackMessages=true");
    localConnection = fac.createConnection();
    localConnection.setClientID("local");
    localConnection.start();
    fac = new ActiveMQConnectionFactory("failover:(" + remoteURI + "," + localURI + ")?randomize=false&backup=false&trackMessages=true");
    fac.sereplacedchTopicAdvisories(false);
    remoteConnection = fac.createConnection();
    remoteConnection.setClientID("remote");
    remoteConnection.start();
    localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

16 View Complete Implementation : FailoverTimeoutTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testTimoutDoesNotFailConnectionAttempts() throws Exception {
    server.stop();
    long timeout = 1000;
    long startTime = System.currentTimeMillis();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri + ")" + "?timeout=" + timeout + "&useExponentialBackOff=false" + "&maxReconnectAttempts=5" + "&initialReconnectDelay=1000");
    Connection connection = cf.createConnection();
    try {
        connection.start();
        fail("Should have failed to connect");
    } catch (JMSException ex) {
        LOG.info("Caught exception on call to start: {}", ex.getMessage());
    }
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    LOG.info("Time spent waiting to connect: {} ms", duration);
    replacedertTrue(duration > 3000);
}

16 View Complete Implementation : FailoverTransactionTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testFailoverProducerCloseBeforeTransactionFailWhenDisabled() throws Exception {
    LOG.info(this + " running test testFailoverProducerCloseBeforeTransactionFailWhenDisabled");
    startCleanBroker();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?trackTransactionProducers=false");
    configureConnectionFactory(cf);
    Connection connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
    Queue destination = session.createQueue(QUEUE_NAME);
    MessageConsumer consumer = session.createConsumer(destination);
    produceMessage(session, destination);
    // restart to force failover and connection state recovery before the commit
    broker.stop();
    startBroker();
    session.commit();
    // without tracking producers, message will not be replayed on recovery
    replacedert.replacedertNull("we got the message", consumer.receive(5000));
    session.commit();
    connection.close();
}

15 View Complete Implementation : ExceptionListenerTest.java
Copyright Apache License 2.0
Author : apache
public void doFireOnSecurityException(ActiveMQConnectionFactory factory) throws Exception {
    factory.sereplacedchTopicAdvisories(false);
    Connection connection = factory.createConnection();
    connection.setExceptionListener(this);
    try {
        connection.start();
        fail("Expect securityException");
    } catch (JMSSecurityException expected) {
        expected.printStackTrace();
        replacedertTrue("nested security exception: " + expected, expected.getCause() instanceof SecurityException);
    }
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return !exceptionsViaListener.isEmpty();
        }
    });
    Throwable expected = exceptionsViaListener.getFirst();
    replacedertNotNull(expected);
    replacedertNotNull(expected.getCause());
    replacedertTrue("expected exception: " + expected, expected.getCause().getCause() instanceof SecurityException);
    try {
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        fail("Expect error b/c connection is auto closed on security exception above");
    } catch (ConnectionFailedException e) {
    }
}

15 View Complete Implementation : MessageCompressionTest.java
Copyright Apache License 2.0
Author : apache
private ActiveMQTextMessage receiveTestMessage(ActiveMQConnectionFactory factory) throws JMSException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(queue);
    ActiveMQTextMessage rc = (ActiveMQTextMessage) consumer.receive();
    connection.close();
    return rc;
}

15 View Complete Implementation : MessageCompressionTest.java
Copyright Apache License 2.0
Author : apache
private ActiveMQObjectMessage receiveTestObjectMessage(ActiveMQConnectionFactory factory) throws JMSException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(queue);
    ActiveMQObjectMessage rc = (ActiveMQObjectMessage) consumer.receive();
    connection.close();
    return rc;
}

15 View Complete Implementation : MessageCompressionTest.java
Copyright Apache License 2.0
Author : apache
private ActiveMQMapMessage receiveTestMapMessage(ActiveMQConnectionFactory factory) throws JMSException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(queue);
    ActiveMQMapMessage rc = (ActiveMQMapMessage) consumer.receive();
    connection.close();
    return rc;
}

15 View Complete Implementation : TwoBrokerQueueClientsReconnectTest.java
Copyright Apache License 2.0
Author : apache
@Override
public void setUp() throws Exception {
    super.setAutoFail(true);
    super.setUp();
    createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=true"));
    createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=true"));
    // Configure broker connection factory
    ActiveMQConnectionFactory factoryA;
    ActiveMQConnectionFactory factoryB;
    factoryA = (ActiveMQConnectionFactory) getConnectionFactory("BrokerA");
    factoryB = (ActiveMQConnectionFactory) getConnectionFactory("BrokerB");
    // Set prefetch policy
    ActiveMQPrefetchPolicy policy = new ActiveMQPrefetchPolicy();
    policy.setAll(PREFETCH_COUNT);
    factoryA.setPrefetchPolicy(policy);
    factoryB.setPrefetchPolicy(policy);
    msgsClient1 = 0;
    msgsClient2 = 0;
}

15 View Complete Implementation : MessageCompressionTest.java
Copyright Apache License 2.0
Author : apache
private ActiveMQBytesMessage receiveTestBytesMessage(ActiveMQConnectionFactory factory) throws JMSException, UnsupportedEncodingException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(queue);
    ActiveMQBytesMessage rc = (ActiveMQBytesMessage) consumer.receive();
    connection.close();
    return rc;
}

15 View Complete Implementation : TopicBridgeSpringTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected void setUp() throws Exception {
    super.setUp();
    context = createApplicationContext();
    ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
    localConnection = fac.createTopicConnection();
    localConnection.start();
    requestServerSession = localConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    Topic theTopic = requestServerSession.createTopic(getClreplaced().getName());
    requestServerConsumer = requestServerSession.createConsumer(theTopic);
    requestServerConsumer.setMessageListener(this);
    requestServerProducer = requestServerSession.createProducer(null);
    fac = (ActiveMQConnectionFactory) context.getBean("remoteFactory");
    remoteConnection = fac.createTopicConnection();
    remoteConnection.start();
    TopicSession session = remoteConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    requestor = new TopicRequestor(session, theTopic);
}

15 View Complete Implementation : BrokerNetworkWithStuckMessagesTest.java
Copyright Apache License 2.0
Author : apache
@SuppressWarnings("unused")
private Object[] browseQueueWithJms(BrokerService broker) throws Exception {
    Object[] messages = null;
    Connection connection = null;
    Session session = null;
    try {
        URI brokerUri = connector.getUri();
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri.toString());
        connection = connectionFactory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue destination = session.createQueue(queueName);
        QueueBrowser browser = session.createBrowser(destination);
        List<Message> list = new ArrayList<>();
        for (Enumeration<Message> enumn = browser.getEnumeration(); enumn.hasMoreElements(); ) {
            list.add(enumn.nextElement());
        }
        messages = list.toArray();
    } finally {
        if (session != null) {
            session.close();
        }
        if (connection != null) {
            connection.close();
        }
    }
    LOG.info("+Browsed with JMS: " + messages.length);
    return messages;
}

15 View Complete Implementation : MessageCompressionTest.java
Copyright Apache License 2.0
Author : apache
private ActiveMQStreamMessage receiveTestStreamMessage(ActiveMQConnectionFactory factory) throws JMSException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(queue);
    ActiveMQStreamMessage rc = (ActiveMQStreamMessage) consumer.receive();
    connection.close();
    return rc;
}

15 View Complete Implementation : RequestReplyTempDestRemovalAdvisoryRaceTest.java
Copyright Apache License 2.0
Author : apache
private void forwardFailureAdvisory() throws JMSException {
    for (BrokerItem item : brokers.values()) {
        ActiveMQConnectionFactory brokerAFactory = new ActiveMQConnectionFactory(item.broker.getTransportConnectorByScheme("tcp").getName() + "?jms.watchTopicAdvisories=false");
        Connection connection = brokerAFactory.createConnection();
        connection.start();
        connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(AdvisorySupport.getNetworkBridgeForwardFailureAdvisoryTopic()).setMessageListener(new MessageListener() {

            @Override
            public void onMessage(Message message) {
                forwardFailures.incrementAndGet();
            }
        });
    }
}

15 View Complete Implementation : NetworkBrokerDetachTest.java
Copyright Apache License 2.0
Author : apache
protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
    String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
    connectionFactory.setOptimizedMessageDispatch(true);
    connectionFactory.setCopyMessageOnSend(false);
    connectionFactory.setUseCompression(false);
    connectionFactory.setDispatchAsync(false);
    connectionFactory.setUseAsyncSend(false);
    connectionFactory.setOptimizeAcknowledge(false);
    connectionFactory.sereplacedchTopicAdvisories(true);
    ActiveMQPrefetchPolicy qPrefetchPolicy = new ActiveMQPrefetchPolicy();
    qPrefetchPolicy.setQueuePrefetch(100);
    qPrefetchPolicy.setTopicPrefetch(1000);
    connectionFactory.setPrefetchPolicy(qPrefetchPolicy);
    connectionFactory.setAlwaysSyncSend(true);
    return connectionFactory;
}

15 View Complete Implementation : NoRetryDeadLetterTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    ActiveMQConnectionFactory connectionFactory = super.createConnectionFactory();
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setMaximumRedeliveries(0);
    connectionFactory.setRedeliveryPolicy(redeliveryPolicy);
    return connectionFactory;
}

14 View Complete Implementation : FailoverTransactionTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testAutoRollbackWithMissingRedeliveries() throws Exception {
    LOG.info(this + " running test testAutoRollbackWithMissingRedeliveries");
    broker = createBroker();
    broker.start();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
    configureConnectionFactory(cf);
    Connection connection = cf.createConnection();
    try {
        connection.start();
        final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        final Queue destination = producerSession.createQueue(QUEUE_NAME + "?consumer.prefetchSize=1");
        final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
        MessageConsumer consumer = consumerSession.createConsumer(destination);
        produceMessage(producerSession, destination);
        Message msg = consumer.receive(20000);
        replacedert.replacedertNotNull(msg);
        broker.stop();
        broker = createBroker();
        // use empty jdbc store so that default wait(0) for redeliveries will timeout after failover
        broker.start();
        try {
            consumerSession.commit();
            replacedert.fail("expected transaction rolledback ex");
        } catch (TransactionRolledBackException expected) {
        }
        broker.stop();
        broker = createBroker();
        broker.start();
        replacedert.replacedertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000));
    } finally {
        connection.close();
    }
}

14 View Complete Implementation : RollbacksWhileConsumingLargeQueueTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ConnectionFactory createConnectionFactory() throws Exception {
    ActiveMQConnectionFactory answer = (ActiveMQConnectionFactory) super.createConnectionFactory();
    RedeliveryPolicy policy = new RedeliveryPolicy();
    policy.setMaximumRedeliveries(3);
    policy.setRedeliveryDelay(0);
    policy.setInitialRedeliveryDelay(0);
    policy.setUseExponentialBackOff(false);
    answer.setRedeliveryPolicy(policy);
    return answer;
}

14 View Complete Implementation : MQTTNetworkOfBrokersFailoverTest.java
Copyright Apache License 2.0
Author : apache
private CountDownLatch listenForConsumersOn(BrokerService broker) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    URI brokerUri = broker.getVmConnectorURI();
    final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerUri.toASCIIString());
    final Connection connection = cf.createConnection();
    connection.start();
    final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination dest = session.createTopic("ActiveMQ.Advisory.Consumer.Queue.Consumer.foo:AT_LEAST_ONCE.VirtualTopic.foo.bar");
    MessageConsumer consumer = session.createConsumer(dest);
    consumer.setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            latch.countDown();
            // shutdown this connection
            Dispatch.getGlobalQueue().execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        session.close();
                        connection.close();
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    });
    return latch;
}

14 View Complete Implementation : DurableSubInBrokerNetworkTest.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a durable topic subscription, checks that it is propagated
 * in the broker network, removes the subscription and checks that
 * the subscription is removed from remote broker as well.
 *
 * @throws Exception
 */
public void testDurableSubNetwork() throws Exception {
    LOG.info("testDurableSubNetwork started.");
    // create durable sub
    ActiveMQConnectionFactory fact = new ActiveMQConnectionFactory(connector.getConnectUri().toString());
    Connection conn = fact.createConnection();
    conn.setClientID("clientID1");
    Session session = conn.createSession(false, 1);
    Destination dest = session.createTopic(topicName);
    TopicSubscriber sub = session.createDurableSubscriber((Topic) dest, subName);
    LOG.info("Durable subscription of name " + subName + "created.");
    Thread.sleep(100);
    // query durable sub on local and remote broker
    // raise an error if not found
    replacedertTrue(foundSubInLocalBroker(subName));
    replacedertTrue(foundSubInRemoteBrokerByTopicName(topicName));
    // unsubscribe from durable sub
    sub.close();
    session.unsubscribe(subName);
    LOG.info("Unsubscribed from durable subscription.");
    Thread.sleep(100);
    // query durable sub on local and remote broker
    // raise an error if its not removed from both brokers
    replacedertFalse(foundSubInLocalBroker(subName));
    replacedertFalse("Durable subscription not unregistered on remote broker", foundSubInRemoteBrokerByTopicName(topicName));
}

14 View Complete Implementation : FailoverTransactionTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testFailoverMultipleProducerCloseBeforeTransaction() throws Exception {
    LOG.info(this + " running test testFailoverMultipleProducerCloseBeforeTransaction");
    startCleanBroker();
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
    configureConnectionFactory(cf);
    Connection connection = cf.createConnection();
    connection.start();
    Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
    Queue destination = session.createQueue(QUEUE_NAME);
    MessageConsumer consumer = session.createConsumer(destination);
    MessageProducer producer;
    TextMessage message;
    final int count = 10;
    for (int i = 0; i < count; i++) {
        producer = session.createProducer(destination);
        message = session.createTextMessage("Test message: " + count);
        producer.send(message);
        producer.close();
    }
    // restart to force failover and connection state recovery before the commit
    broker.stop();
    startBroker();
    session.commit();
    for (int i = 0; i < count; i++) {
        replacedert.replacedertNotNull("we got all the message: " + count, consumer.receive(20000));
    }
    session.commit();
    connection.close();
}

14 View Complete Implementation : CompressionOverNetworkTest.java
Copyright Apache License 2.0
Author : apache
protected void doSetUp(boolean deleteAllMessages) throws Exception {
    localBroker = createLocalBroker();
    localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    localBroker.start();
    localBroker.waitUntilStarted();
    remoteBroker = createRemoteBroker();
    remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    remoteBroker.start();
    remoteBroker.waitUntilStarted();
    URI localURI = localBroker.getVmConnectorURI();
    ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
    fac.setAlwaysSyncSend(true);
    fac.setDispatchAsync(false);
    localConnection = fac.createConnection();
    localConnection.setClientID("clientId");
    localConnection.start();
    URI remoteURI = remoteBroker.getVmConnectorURI();
    fac = new ActiveMQConnectionFactory(remoteURI);
    remoteConnection = fac.createConnection();
    remoteConnection.setClientID("clientId");
    remoteConnection.start();
    included = new ActiveMQTopic("include.test.bar");
    localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

14 View Complete Implementation : DurableSubInBrokerNetworkTest.java
Copyright Apache License 2.0
Author : apache
public void testTwoDurableSubsInNetworkWithUnsubscribe() throws Exception {
    // create 1st durable sub to topic TEST.FOO
    ActiveMQConnectionFactory fact = new ActiveMQConnectionFactory(connector.getConnectUri().toString());
    Connection conn = fact.createConnection();
    conn.setClientID("clientID1");
    Session session = conn.createSession(false, 1);
    Destination dest = session.createTopic(topicName);
    TopicSubscriber sub = session.createDurableSubscriber((Topic) dest, subName);
    LOG.info("Durable subscription of name " + subName + "created.");
    TopicSubscriber sub2 = session.createDurableSubscriber((Topic) dest, subName2);
    LOG.info("Durable subscription of name " + subName2 + "created.");
    Thread.sleep(100);
    // query durable sub on local and remote broker
    // raise an error if not found
    replacedertTrue(foundSubInLocalBroker(subName));
    replacedertTrue(foundSubInLocalBroker(subName2));
    replacedertTrue(foundSubInRemoteBrokerByTopicName(topicName));
    // unsubscribe from durable sub
    sub.close();
    session.unsubscribe(subName);
    LOG.info("Unsubscribed from durable subscription.");
    Thread.sleep(100);
    // query durable sub on local and remote broker
    replacedertFalse(foundSubInLocalBroker(subName));
    replacedertTrue(foundSubInLocalBroker(subName2));
    replacedertTrue("Durable subscription should still be on remote broker", foundSubInRemoteBrokerByTopicName(topicName));
    sub2.close();
    session.unsubscribe(subName2);
    Thread.sleep(100);
    replacedertFalse(foundSubInLocalBroker(subName2));
    replacedertFalse("Durable subscription not unregistered on remote broker", foundSubInRemoteBrokerByTopicName(topicName));
}

14 View Complete Implementation : DiscoveryTransportNoBrokerTest.java
Copyright Apache License 2.0
Author : apache
public void testNoExtraThreads() throws Exception {
    BrokerService broker = new BrokerService();
    TransportConnector tcp = broker.addConnector("tcp://localhost:0?transport.closeAsync=false");
    String group = "GR-" + System.currentTimeMillis();
    URI discoveryUri = new URI("multicast://default?group=" + group);
    tcp.setDiscoveryUri(discoveryUri);
    broker.start();
    broker.waitUntilStarted();
    Vector<String> existingNames = new Vector<>();
    Thread[] threads = getThreads();
    for (Thread t : threads) {
        existingNames.add(t.getName());
    }
    final int idleThreadCount = threads.length;
    LOG.info("Broker started - thread Count:" + idleThreadCount);
    final int noConnectionToCreate = 10;
    for (int i = 0; i < 10; i++) {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://239.255.2.3:6155?group=" + group + ")?closeAsync=false&startupMaxReconnectAttempts=10&initialReconnectDelay=1000");
        LOG.info("Connecting.");
        Connection connection = factory.createConnection();
        connection.setClientID("test");
        connection.close();
    }
    Thread.sleep(2000);
    threads = getThreads();
    for (Thread t : threads) {
        if (!existingNames.contains(t.getName())) {
            LOG.info("Remaining thread:" + t);
        }
    }
    replacedertTrue("no extra threads per connection", Thread.activeCount() - idleThreadCount < noConnectionToCreate);
}

14 View Complete Implementation : NetworkReconnectTest.java
Copyright Apache License 2.0
Author : apache
protected AtomicInteger createConsumerCounter(ActiveMQConnectionFactory cf) throws Exception {
    final AtomicInteger rc = new AtomicInteger(0);
    Connection connection = cf.createConnection();
    connections.add(connection);
    connection.start();
    ConsumerEventSource source = new ConsumerEventSource(connection, destination);
    source.setConsumerListener(new ConsumerListener() {

        @Override
        public void onConsumerEvent(ConsumerEvent event) {
            rc.set(event.getConsumerCount());
        }
    });
    source.start();
    return rc;
}

14 View Complete Implementation : StoreUsageTest.java
Copyright Apache License 2.0
Author : apache
public void testJmx() throws Exception {
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
    Connection conn = factory.createConnection();
    conn.start();
    Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination dest = sess.createQueue(this.getClreplaced().getName());
    final ProducerThread producer = new ProducerThread(sess, dest);
    producer.start();
    // wait for the producer to block
    Thread.sleep(WAIT_TIME_MILLS / 2);
    broker.getAdminView().setStoreLimit(1024 * 1024);
    Thread.sleep(WAIT_TIME_MILLS);
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            return producer.getSentCount() == producer.getMessageCount();
        }
    }, WAIT_TIME_MILLS * 2);
    replacedertEquals("Producer didn't send all messages", producer.getMessageCount(), producer.getSentCount());
}

14 View Complete Implementation : LDAPAuthenticationTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testWildcard() throws Exception {
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    Connection conn = factory.createQueueConnection("*", "sunflower");
    try {
        conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    fail("Should have failed connecting");
}

14 View Complete Implementation : FailoverTimeoutTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testUpdateUris() throws Exception {
    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri + ")?useExponentialBackOff=false");
    ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
    try {
        connection.start();
        FailoverTransport failoverTransport = connection.getTransport().narrow(FailoverTransport.clreplaced);
        URI[] bunchOfUnknownAndOneKnown = new URI[] { new URI("tcp://unknownHost:" + tcpUri.getPort()), new URI("tcp://unknownHost2:" + tcpUri.getPort()), new URI("tcp://localhost:2222") };
        failoverTransport.add(false, bunchOfUnknownAndOneKnown);
    } finally {
        if (connection != null) {
            connection.close();
        }
    }
}

13 View Complete Implementation : SimpleNetworkTest.java
Copyright Apache License 2.0
Author : apache
protected void doSetUp(boolean deleteAllMessages) throws Exception {
    remoteBroker = createRemoteBroker();
    remoteBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    remoteBroker.start();
    remoteBroker.waitUntilStarted();
    localBroker = createLocalBroker();
    localBroker.setDeleteAllMessagesOnStartup(deleteAllMessages);
    localBroker.start();
    localBroker.waitUntilStarted();
    URI localURI = localBroker.getVmConnectorURI();
    ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(localURI);
    fac.setAlwaysSyncSend(true);
    fac.setDispatchAsync(false);
    localConnection = fac.createConnection();
    localConnection.setClientID("clientId");
    localConnection.start();
    URI remoteURI = remoteBroker.getVmConnectorURI();
    fac = new ActiveMQConnectionFactory(remoteURI);
    remoteConnection = fac.createConnection();
    remoteConnection.setClientID("clientId");
    remoteConnection.start();
    included = new ActiveMQTopic("include.test.bar");
    excluded = new ActiveMQTopic("exclude.test.bar");
    localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

13 View Complete Implementation : AdvisoryNetworkBridgeTest.java
Copyright Apache License 2.0
Author : apache
public void testAddConsumerLater() throws Exception {
    createBroker1();
    createBroker2();
    Thread.sleep(1000);
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://broker1");
    Connection conn = factory.createConnection();
    Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    conn.start();
    MessageConsumer consumer = sess.createConsumer(AdvisorySupport.getNetworkBridgeAdvisoryTopic());
    ActiveMQMessage advisory = (ActiveMQMessage) consumer.receive(2000);
    replacedertNotNull(advisory);
    replacedertTrue(advisory.getDataStructure() instanceof BrokerInfo);
    replacedertTrue(advisory.getBooleanProperty("started"));
    replacedertCreatedByDuplex(advisory.getBooleanProperty("createdByDuplex"));
    broker2.stop();
    broker2.waitUntilStopped();
    advisory = (ActiveMQMessage) consumer.receive(2000);
    replacedertNotNull(advisory);
    replacedertTrue(advisory.getDataStructure() instanceof BrokerInfo);
    replacedertFalse(advisory.getBooleanProperty("started"));
    consumer = sess.createConsumer(AdvisorySupport.getNetworkBridgeAdvisoryTopic());
    advisory = (ActiveMQMessage) consumer.receive(1000);
    replacedertNull(advisory);
    conn.close();
}

13 View Complete Implementation : BrokerXmlConfigFromJNDITest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    replacedertBaseDirectoryContainsSpaces();
    // we could put these properties into a jndi.properties
    // on the clreplacedpath instead
    Hashtable<String, String> properties = new Hashtable<>();
    properties.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
    // configure the embedded broker using an XML config file
    // which is either a URL or a resource on the clreplacedpath
    File f = new File(System.getProperty("basedir", "."), "/src/test/resources/activemq.xml");
    properties.put(Context.PROVIDER_URL, "vm://localhost?brokerConfig=xbean:" + f.toURI());
    InitialContext context = new InitialContext(properties);
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory");
    // END SNIPPET: example
    return connectionFactory;
}

13 View Complete Implementation : MessageListenerDeadLetterTest.java
Copyright Apache License 2.0
Author : apache
@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
    ActiveMQConnectionFactory answer = super.createConnectionFactory();
    RedeliveryPolicy policy = new RedeliveryPolicy();
    policy.setMaximumRedeliveries(3);
    policy.setBackOffMultiplier((short) 1);
    policy.setRedeliveryDelay(0);
    policy.setInitialRedeliveryDelay(0);
    policy.setUseExponentialBackOff(false);
    answer.setRedeliveryPolicy(policy);
    return answer;
}

13 View Complete Implementation : InitialContextTest.java
Copyright Apache License 2.0
Author : apache
public void testConnectionFactoryPolicyConfig() throws Exception {
    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
    properties.put(Context.PROVIDER_URL, "tcp://localhost:65432");
    properties.put("prefetchPolicy.queuePrefetch", "777");
    properties.put("redeliveryPolicy.maximumRedeliveries", "15");
    properties.put("redeliveryPolicy.backOffMultiplier", "32");
    InitialContext context = new InitialContext(properties);
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) context.lookup("ConnectionFactory");
    replacedertTrue("Should have created a ConnectionFactory", connectionFactory != null);
    replacedertEquals(777, connectionFactory.getPrefetchPolicy().getQueuePrefetch());
    replacedertEquals(15, connectionFactory.getRedeliveryPolicy().getMaximumRedeliveries());
    replacedertEquals(32d, connectionFactory.getRedeliveryPolicy().getBackOffMultiplier());
}