Search in sources :

Example 6 with WildcardConfiguration

use of org.apache.activemq.artemis.core.config.WildcardConfiguration in project activemq-artemis by apache.

the class FileConfigurationParser method parseWildcardConfiguration.

/**
 * @param e
 * @return
 */
protected void parseWildcardConfiguration(final Element e, final Configuration mainConfig) {
    WildcardConfiguration conf = mainConfig.getWildcardConfiguration();
    conf.setDelimiter(getString(e, "delimiter", Character.toString(conf.getDelimiter()), Validators.NO_CHECK).charAt(0));
    conf.setAnyWords(getString(e, "any-words", Character.toString(conf.getAnyWords()), Validators.NO_CHECK).charAt(0));
    conf.setSingleWord(getString(e, "single-word", Character.toString(conf.getSingleWord()), Validators.NO_CHECK).charAt(0));
    conf.setRoutingEnabled(getBoolean(e, "enabled", conf.isRoutingEnabled()));
    conf.setRoutingEnabled(getBoolean(e, "routing-enabled", conf.isRoutingEnabled()));
}
Also used : WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration)

Example 7 with WildcardConfiguration

use of org.apache.activemq.artemis.core.config.WildcardConfiguration in project activemq-artemis by apache.

the class WildcardAddressManagerUnitTest method testWildCardAddressRemovalDifferentWildcard.

@Test
public void testWildCardAddressRemovalDifferentWildcard() throws Exception {
    final WildcardConfiguration configuration = new WildcardConfiguration();
    configuration.setAnyWords('>');
    WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), configuration, null);
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.>"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test"), RoutingType.MULTICAST));
    ad.addBinding(new BindingFake("Topic1.>", "one"));
    assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
    assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
    assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
    assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
    // Remove the address
    ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.test"));
    // should still have 1 address and binding
    assertEquals(1, ad.getAddresses().size());
    assertEquals(1, ad.getBindings().size());
    ad.removeBinding(SimpleString.toSimpleString("one"), null);
    ad.removeAddressInfo(SimpleString.toSimpleString("Topic1.>"));
    assertEquals(0, ad.getAddresses().size());
    assertEquals(0, ad.getBindings().size());
}
Also used : WildcardAddressManager(org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 8 with WildcardConfiguration

use of org.apache.activemq.artemis.core.config.WildcardConfiguration in project activemq-artemis by apache.

the class WildcardAddressManagerUnitTest method testWildCardAddressDirectBindings.

@Test
public void testWildCardAddressDirectBindings() throws Exception {
    final WildcardConfiguration configuration = new WildcardConfiguration();
    configuration.setAnyWords('>');
    WildcardAddressManager ad = new WildcardAddressManager(new BindingFactoryFake(), configuration, null);
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.>"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test.test1"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic1.test.test2"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic2.>"), RoutingType.MULTICAST));
    ad.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("Topic2.test"), RoutingType.MULTICAST));
    ad.addBinding(new BindingFake("Topic1.>", "one"));
    ad.addBinding(new BindingFake("Topic1.test", "two"));
    ad.addBinding(new BindingFake("Topic2.test", "three"));
    assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
    assertEquals(2, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
    assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test.test1")).getBindings().size());
    assertEquals(1, ad.getBindingsForRoutingAddress(SimpleString.toSimpleString("Topic1.test.test2")).getBindings().size());
    assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.>")).getBindings().size());
    assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test")).getBindings().size());
    assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test1")).getBindings().size());
    assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic1.test2")).getBindings().size());
    assertEquals(0, ad.getDirectBindings(SimpleString.toSimpleString("Topic2.>")).getBindings().size());
    assertEquals(1, ad.getDirectBindings(SimpleString.toSimpleString("Topic2.test")).getBindings().size());
}
Also used : WildcardAddressManager(org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 9 with WildcardConfiguration

use of org.apache.activemq.artemis.core.config.WildcardConfiguration in project activemq-artemis by apache.

the class FileConfigurationParserTest method testWildcardConfiguration.

@Test
public void testWildcardConfiguration() throws Exception {
    FileConfigurationParser parser = new FileConfigurationParser();
    String configStr = firstPart + "<wildcard-addresses>\n<routing-enabled>true</routing-enabled>\n<delimiter>/</delimiter>\n<any-words>></any-words></wildcard-addresses>" + lastPart;
    ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));
    Configuration config = parser.parseMainConfig(input);
    WildcardConfiguration wildCard = config.getWildcardConfiguration();
    assertEquals('/', wildCard.getDelimiter());
    assertTrue(wildCard.isRoutingEnabled());
    assertEquals('>', wildCard.getAnyWords());
    assertEquals('*', wildCard.getSingleWord());
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) FileConfigurationParser(org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser) Test(org.junit.Test)

Example 10 with WildcardConfiguration

use of org.apache.activemq.artemis.core.config.WildcardConfiguration in project activemq-artemis by apache.

the class MQTTSecurityCRLTest method addWildCardConfiguration.

private void addWildCardConfiguration(Configuration configuration) {
    WildcardConfiguration wildcardConfiguration = new WildcardConfiguration();
    wildcardConfiguration.setAnyWords('#');
    wildcardConfiguration.setDelimiter('/');
    wildcardConfiguration.setRoutingEnabled(true);
    wildcardConfiguration.setSingleWord('+');
    configuration.setWildCardConfiguration(wildcardConfiguration);
}
Also used : WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration)

Aggregations

WildcardConfiguration (org.apache.activemq.artemis.core.config.WildcardConfiguration)14 Test (org.junit.Test)8 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 WildcardAddressManager (org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager)2 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)2 HierarchicalObjectRepository (org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository)2 BlockingConnection (org.fusesource.mqtt.client.BlockingConnection)2 Message (org.fusesource.mqtt.client.Message)2 Topic (org.fusesource.mqtt.client.Topic)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)1 CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)1 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)1 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)1 FileConfigurationParser (org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser)1 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)1 Before (org.junit.Before)1