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