Search in sources :

Example 1 with PersistedConnectionFactory

use of org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory in project activemq-artemis by apache.

the class JMSServerManagerImpl method initJournal.

/**
 * @throws Exception
 */
private void initJournal() throws Exception {
    this.coreConfig = server.getConfiguration();
    createJournal();
    storage.load();
    List<PersistedConnectionFactory> cfs = storage.recoverConnectionFactories();
    for (PersistedConnectionFactory cf : cfs) {
        internalCreateCF(cf.getConfig());
    }
    List<PersistedDestination> destinations = storage.recoverDestinations();
    for (PersistedDestination destination : destinations) {
        if (destination.getType() == PersistedType.Queue) {
            internalCreateQueue(destination.getName(), destination.getSelector(), destination.isDurable());
        } else if (destination.getType() == PersistedType.Topic) {
            internalCreateTopic(destination.getName());
        }
    }
}
Also used : PersistedDestination(org.apache.activemq.artemis.jms.persistence.config.PersistedDestination) PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory)

Example 2 with PersistedConnectionFactory

use of org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory in project activemq-artemis by apache.

the class JMSServerManagerImpl method recreateCF.

@Override
public synchronized ActiveMQConnectionFactory recreateCF(String name, ConnectionFactoryConfiguration cf) throws Exception {
    List<String> bindings = connectionFactoryBindings.get(name);
    if (bindings == null) {
        throw ActiveMQJMSServerBundle.BUNDLE.cfDoesntExist(name);
    }
    String[] usedBindings = bindings.toArray(new String[bindings.size()]);
    ActiveMQConnectionFactory realCF = internalCreateCFPOJO(cf);
    if (cf.isPersisted()) {
        storage.storeConnectionFactory(new PersistedConnectionFactory(cf));
        storage.addBindings(PersistedType.ConnectionFactory, cf.getName(), usedBindings);
    }
    for (String bindingsElement : usedBindings) {
        this.bindToBindings(bindingsElement, realCF);
    }
    return realCF;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 3 with PersistedConnectionFactory

use of org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory in project activemq-artemis by apache.

the class JMSConnectionFactoryConfigurationStorageTest method testSettingsWithConnectorConfigs.

@Test
public void testSettingsWithConnectorConfigs() throws Exception {
    createJMSStorage();
    String[] str = new String[5];
    for (int i = 0; i < 5; i++) {
        str[i] = "str" + i;
    }
    List<String> connectorConfigs = new ArrayList<>();
    Map<String, Object> liveParams = new HashMap<>();
    liveParams.put(TransportConstants.PORT_PROP_NAME, 5665);
    Map<String, Object> backupParams = new HashMap<>();
    backupParams.put(TransportConstants.PORT_PROP_NAME, 5775);
    Map<String, Object> liveParams2 = new HashMap<>();
    liveParams2.put(TransportConstants.PORT_PROP_NAME, 6665);
    ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("some-name").setConnectorNames(connectorConfigs).setBindings(str).setCallTimeout(RandomUtil.randomPositiveLong());
    List<Pair<String, String>> connectors = new ArrayList<>();
    connectors.add(new Pair<String, String>(RandomUtil.randomString(), null));
    // config.setConnectorNames(connectors);
    addSetting(new PersistedConnectionFactory(config));
    jmsJournal.stop();
    createJMSStorage();
    List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
    assertEquals(1, cfs.size());
    assertEquals("some-name", cfs.get(0).getName());
    assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Pair(org.apache.activemq.artemis.api.core.Pair) Test(org.junit.Test)

Example 4 with PersistedConnectionFactory

use of org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory in project activemq-artemis by apache.

the class JMSConnectionFactoryConfigurationStorageTest method testSizeOfCF.

@Test
public void testSizeOfCF() throws Exception {
    String[] str = new String[5];
    for (int i = 0; i < 5; i++) {
        str[i] = "str" + i;
    }
    ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("some-name").setConnectorNames(new ArrayList<String>()).setBindings("");
    int size = config.getEncodeSize();
    ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(size);
    config.encode(buffer);
    assertEquals(size, buffer.writerIndex());
    PersistedConnectionFactory persistedCF = new PersistedConnectionFactory(config);
    size = persistedCF.getEncodeSize();
    buffer = ActiveMQBuffers.fixedBuffer(size);
    persistedCF.encode(buffer);
    assertEquals(size, buffer.writerIndex());
}
Also used : PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ArrayList(java.util.ArrayList) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 5 with PersistedConnectionFactory

use of org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory in project activemq-artemis by apache.

the class JMSConnectionFactoryConfigurationStorageTest method testSettings.

@Test
public void testSettings() throws Exception {
    createJMSStorage();
    List<String> transportConfigs = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        transportConfigs.add("c1-" + i);
        transportConfigs.add("c2-" + i);
    }
    ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("some-name").setConnectorNames(transportConfigs);
    addSetting(new PersistedConnectionFactory(config));
    jmsJournal.stop();
    createJMSStorage();
    List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
    assertEquals(1, cfs.size());
    assertEquals("some-name", cfs.get(0).getName());
    PersistedConnectionFactory cf1 = cfs.get(0);
    assertEquals(10, cf1.getConfig().getConnectorNames().size());
    List<String> configs = cf1.getConfig().getConnectorNames();
    for (int i = 0, j = 0; i < 10; i += 2, j++) {
        assertEquals(configs.get(i), "c1-" + j);
        assertEquals(configs.get(i + 1), "c2-" + j);
    }
}
Also used : PersistedConnectionFactory(org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ArrayList(java.util.ArrayList) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Test(org.junit.Test)

Aggregations

PersistedConnectionFactory (org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory)6 ArrayList (java.util.ArrayList)4 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)3 ConnectionFactoryConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl)3 Test (org.junit.Test)3 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)2 Pair (org.apache.activemq.artemis.api.core.Pair)2 PersistedDestination (org.apache.activemq.artemis.jms.persistence.config.PersistedDestination)2 HashMap (java.util.HashMap)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 PreparedTransactionInfo (org.apache.activemq.artemis.core.journal.PreparedTransactionInfo)1 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)1 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 PersistedBindings (org.apache.activemq.artemis.jms.persistence.config.PersistedBindings)1 PersistedType (org.apache.activemq.artemis.jms.persistence.config.PersistedType)1