Search in sources :

Example 1 with TransportConnection

use of org.apache.activemq.broker.TransportConnection in project activemq-artemis by apache.

the class DynamicallyIncludedDestinationsDuplexNetworkTest method testDynamicallyIncludedDestinationsForDuplex.

@Test
public void testDynamicallyIncludedDestinationsForDuplex() throws Exception {
    // Once the bridge is set up, we should see the filter used for the duplex end of the bridge
    // only subscribe to the specific destinations included in the <dynamicallyIncludedDestinations> list
    // so let's test that the filter is correct, let's also test the subscription on the localbroker
    // is correct
    // the bridge on the remote broker has the correct filter
    TransportConnection bridgeConnection = getDuplexBridgeConnectionFromRemote();
    assertNotNull(bridgeConnection);
    DemandForwardingBridge duplexBridge = getDuplexBridgeFromConnection(bridgeConnection);
    assertNotNull(duplexBridge);
    NetworkBridgeConfiguration configuration = getConfigurationFromNetworkBridge(duplexBridge);
    assertNotNull(configuration);
    assertFalse("This destinationFilter does not include ONLY the destinations specified in dynamicallyIncludedDestinations", configuration.getDestinationFilter().equals(AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + ">"));
    assertEquals("There are other patterns in the destinationFilter that shouldn't be there", "ActiveMQ.Advisory.Consumer.Queue.include.test.foo,ActiveMQ.Advisory.Consumer.Topic.include.test.bar", configuration.getDestinationFilter());
}
Also used : TransportConnection(org.apache.activemq.broker.TransportConnection) Test(org.junit.Test)

Example 2 with TransportConnection

use of org.apache.activemq.broker.TransportConnection in project activemq-artemis by apache.

the class SimpleAuthenticationPluginTest method testSecurityContextClearedOnPurge.

public void testSecurityContextClearedOnPurge() throws Exception {
    connection.close();
    ActiveMQConnectionFactory tcpFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
    ActiveMQConnection conn = (ActiveMQConnection) tcpFactory.createConnection("user", "password");
    Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    conn.start();
    final int numDests = broker.getRegionBroker().getDestinations().length;
    for (int i = 0; i < 10; i++) {
        MessageProducer p = sess.createProducer(new ActiveMQQueue("USERS.PURGE." + i));
        p.close();
    }
    assertTrue("dests are purged", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            LOG.info("dests, orig: " + numDests + ", now: " + broker.getRegionBroker().getDestinations().length);
            return (numDests + 1) == broker.getRegionBroker().getDestinations().length;
        }
    }));
    // verify removed from connection security context
    TransportConnection brokerConnection = broker.getTransportConnectors().get(0).getConnections().get(0);
    TransportConnectionState transportConnectionState = brokerConnection.lookupConnectionState(conn.getConnectionInfo().getConnectionId());
    assertEquals("no destinations", 0, transportConnectionState.getContext().getSecurityContext().getAuthorizedWriteDests().size());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnection(org.apache.activemq.broker.TransportConnection) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) TransportConnectionState(org.apache.activemq.broker.TransportConnectionState) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Example 3 with TransportConnection

use of org.apache.activemq.broker.TransportConnection in project activemq-artemis by apache.

the class ActiveMQXAConnectionFactoryTest method assertTransactionGoneFromConnection.

private void assertTransactionGoneFromConnection(String brokerName, String clientId, ConnectionId connectionId, Xid tid) throws Exception {
    BrokerService broker = BrokerRegistry.getInstance().lookup(brokerName);
    CopyOnWriteArrayList<TransportConnection> connections = broker.getTransportConnectors().get(0).getConnections();
    for (TransportConnection connection : connections) {
        if (connection.getConnectionId().equals(clientId)) {
            try {
                connection.processPrepareTransaction(new TransactionInfo(connectionId, new XATransactionId(tid), TransactionInfo.PREPARE));
                fail("did not get expected exception on missing transaction, it must be still there in error!");
            } catch (IllegalStateException expectedOnNoTransaction) {
            }
        }
    }
}
Also used : TransportConnection(org.apache.activemq.broker.TransportConnection) XATransactionId(org.apache.activemq.command.XATransactionId) TransactionInfo(org.apache.activemq.command.TransactionInfo) BrokerService(org.apache.activemq.broker.BrokerService)

Example 4 with TransportConnection

use of org.apache.activemq.broker.TransportConnection in project activemq-artemis by apache.

the class DynamicallyIncludedDestinationsDuplexNetworkTest method getDuplexBridgeConnectionFromRemote.

public TransportConnection getDuplexBridgeConnectionFromRemote() {
    TransportConnector transportConnector = remoteBroker.getTransportConnectorByScheme("tcp");
    CopyOnWriteArrayList<TransportConnection> transportConnections = transportConnector.getConnections();
    TransportConnection duplexBridgeConnectionFromRemote = transportConnections.get(0);
    return duplexBridgeConnectionFromRemote;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) TransportConnection(org.apache.activemq.broker.TransportConnection)

Aggregations

TransportConnection (org.apache.activemq.broker.TransportConnection)4 MessageProducer (javax.jms.MessageProducer)1 Session (javax.jms.Session)1 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 BrokerService (org.apache.activemq.broker.BrokerService)1 TransportConnectionState (org.apache.activemq.broker.TransportConnectionState)1 TransportConnector (org.apache.activemq.broker.TransportConnector)1 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)1 TransactionInfo (org.apache.activemq.command.TransactionInfo)1 XATransactionId (org.apache.activemq.command.XATransactionId)1 Test (org.junit.Test)1