use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class FailoverWithDivertTest method addQueue.
private void addQueue(Configuration serverConfig, String address, String name) {
List<CoreAddressConfiguration> addrConfigs = serverConfig.getAddressConfigurations();
CoreAddressConfiguration addrCfg = new CoreAddressConfiguration();
addrCfg.setName(address);
addrCfg.addRoutingType(RoutingType.ANYCAST);
CoreQueueConfiguration qConfig = new CoreQueueConfiguration();
qConfig.setName(name);
qConfig.setAddress(address);
addrCfg.addQueueConfiguration(qConfig);
addrConfigs.add(addrCfg);
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class AutomaticColocatedQuorumVoteTest method getConfiguration.
private Configuration getConfiguration(String identity, boolean scaleDown, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor, TransportConfiguration... otherLiveNodes) throws Exception {
Configuration configuration = createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(liveAcceptor).addConnectorConfiguration(liveConnector.getName(), liveConnector).setJournalDirectory(getJournalDir() + identity).setBindingsDirectory(getBindingsDir() + identity).setLargeMessagesDirectory(getLargeMessagesDir() + identity).setPagingDirectory(getPageDir() + identity).addQueueConfiguration(new CoreQueueConfiguration().setAddress("testQueue").setName("testQueue"));
List<String> transportConfigurationList = new ArrayList<>();
final ColocatedPolicyConfiguration haPolicy = new ColocatedPolicyConfiguration();
for (TransportConfiguration otherLiveNode : otherLiveNodes) {
configuration.addConnectorConfiguration(otherLiveNode.getName(), otherLiveNode);
transportConfigurationList.add(otherLiveNode.getName());
haPolicy.getExcludedConnectors().add(otherLiveNode.getName());
}
String[] input = new String[transportConfigurationList.size()];
transportConfigurationList.toArray(input);
configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), input));
haPolicy.setBackupPortOffset(100);
haPolicy.setBackupRequestRetries(-1);
haPolicy.setBackupRequestRetryInterval(500);
haPolicy.setMaxBackups(1);
haPolicy.setRequestBackup(true);
configuration.setHAPolicyConfiguration(haPolicy);
if (!replicated) {
SharedStoreMasterPolicyConfiguration ssmc = new SharedStoreMasterPolicyConfiguration();
SharedStoreSlavePolicyConfiguration sssc = new SharedStoreSlavePolicyConfiguration();
haPolicy.setLiveConfig(ssmc);
haPolicy.setBackupConfig(sssc);
if (scaleDown) {
sssc.setScaleDownConfiguration(new ScaleDownConfiguration());
}
} else {
ReplicatedPolicyConfiguration rpc = new ReplicatedPolicyConfiguration();
ReplicaPolicyConfiguration rpc2 = new ReplicaPolicyConfiguration();
haPolicy.setLiveConfig(rpc);
haPolicy.setBackupConfig(rpc2);
if (scaleDown) {
rpc2.setScaleDownConfiguration(new ScaleDownConfiguration());
}
}
return configuration;
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class PredefinedQueueTest method testDurableNonDurable.
@Test
public void testDurableNonDurable() throws Exception {
final String testAddress = "testAddress";
final String queueName1 = "queue1";
final String queueName2 = "queue2";
CoreQueueConfiguration queue1 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName1).setDurable(false);
CoreQueueConfiguration queue2 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName2);
List<CoreQueueConfiguration> queueConfs = new ArrayList<>();
queueConfs.add(queue1);
queueConfs.add(queue2);
configuration.addQueueConfiguration(queue1).addQueueConfiguration(queue2);
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration));
server.start();
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = addClientSession(sf.createSession(false, true, true));
ClientProducer producer = session.createProducer(new SimpleString(testAddress));
final SimpleString propKey = new SimpleString("testkey");
final int numMessages = 1;
PredefinedQueueTest.log.info("sending messages");
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session.createMessage(true);
message.putIntProperty(propKey, i);
producer.send(message);
}
session.close();
PredefinedQueueTest.log.info("stopping");
sf.close();
server.stop();
server.start();
sf = createSessionFactory(locator);
session = addClientSession(sf.createSession(false, true, true));
session.start();
ClientConsumer consumer1 = session.createConsumer(queueName1);
ClientConsumer consumer2 = session.createConsumer(queueName2);
ClientMessage message = consumer1.receiveImmediate();
Assert.assertNull(message);
for (int i = 0; i < numMessages; i++) {
message = consumer2.receive(200);
Assert.assertNotNull(message);
Assert.assertEquals(i, message.getObjectProperty(propKey));
message.acknowledge();
}
Assert.assertNull(consumer1.receiveImmediate());
Assert.assertNull(consumer2.receiveImmediate());
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class PredefinedQueueTest method testDeploySameNames.
@Test
public void testDeploySameNames() throws Exception {
final String testAddress = "testAddress";
final String queueName1 = "queue1";
final String queueName2 = "queue2";
CoreQueueConfiguration queue1 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName1);
CoreQueueConfiguration queue2 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName2);
configuration.addQueueConfiguration(queue1).addQueueConfiguration(queue2);
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
server.start();
Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(testAddress));
Assert.assertEquals(2, bindings.getBindings().size());
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = addClientSession(sf.createSession(false, true, true));
session.start();
ClientProducer producer = addClientProducer(session.createProducer(new SimpleString(testAddress)));
ClientConsumer consumer1 = addClientConsumer(session.createConsumer(queueName1));
ClientConsumer consumer2 = addClientConsumer(session.createConsumer(queueName2));
final int numMessages = 10;
final SimpleString propKey = new SimpleString("testkey");
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session.createMessage(false);
message.putIntProperty(propKey, i);
producer.send(message);
}
for (int i = 0; i < numMessages; i++) {
ClientMessage message = consumer1.receive(200);
Assert.assertNotNull(message);
Assert.assertEquals(i, message.getObjectProperty(propKey));
message.acknowledge();
message = consumer2.receive(200);
Assert.assertNotNull(message);
Assert.assertEquals(i, message.getObjectProperty(propKey));
message.acknowledge();
}
Assert.assertNull(consumer1.receiveImmediate());
Assert.assertNull(consumer2.receiveImmediate());
}
use of org.apache.activemq.artemis.core.config.CoreQueueConfiguration in project activemq-artemis by apache.
the class PredefinedQueueTest method testDeployWithFilter.
@Test
public void testDeployWithFilter() throws Exception {
final String testAddress = "testAddress";
final String queueName1 = "queue1";
final String filter = "cheese='camembert'";
CoreQueueConfiguration queue1 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName1).setFilterString(filter).setDurable(false);
configuration.addQueueConfiguration(queue1);
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
server.start();
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = addClientSession(sf.createSession(false, true, true));
ClientProducer producer = session.createProducer(new SimpleString(testAddress));
final SimpleString propKey = new SimpleString("testkey");
final int numMessages = 1;
PredefinedQueueTest.log.info("sending messages");
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session.createMessage(true);
message.putStringProperty(new SimpleString("cheese"), new SimpleString("camembert"));
message.putIntProperty(propKey, i);
producer.send(message);
}
session.start();
ClientConsumer consumer1 = session.createConsumer(queueName1);
for (int i = 0; i < numMessages; i++) {
ClientMessage message = consumer1.receive(200);
Assert.assertNotNull(message);
Assert.assertEquals(i, message.getObjectProperty(propKey));
message.acknowledge();
}
Assert.assertNull(consumer1.receiveImmediate());
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session.createMessage(true);
message.putStringProperty(new SimpleString("cheese"), new SimpleString("roquefort"));
message.putIntProperty(propKey, i);
producer.send(message);
}
Assert.assertNull(consumer1.receiveImmediate());
}
Aggregations