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());
}
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());
}
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) {
}
}
}
}
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;
}
Aggregations