use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ZeroPrefetchConsumerTest method createArtemisBroker.
@Override
public EmbeddedJMS createArtemisBroker() throws Exception {
Configuration config0 = createConfig("localhost", 0);
String coreQueueAddress = brokerZeroQueue.getQueueName();
AddressSettings addrSettings = new AddressSettings();
addrSettings.setQueuePrefetch(0);
config0.getAddressesSettings().put(coreQueueAddress, addrSettings);
EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
return newbroker;
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ConsumerCloseTest method setUp.
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultInVMConfig();
server = addServer(ActiveMQServers.newActiveMQServer(config, false));
server.start();
address = RandomUtil.randomSimpleString();
queue = RandomUtil.randomSimpleString();
locator = createInVMNonHALocator();
sf = createSessionFactory(locator);
session = addClientSession(sf.createSession(false, true, true));
session.createQueue(address, queue, false);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class QueueAutoCreationTest method configureAddressPolicy.
@Override
protected void configureAddressPolicy(ActiveMQServer server) {
Configuration serverConfig = server.getConfiguration();
serverConfig.setJournalType(JournalType.NIO);
Map<String, AddressSettings> map = serverConfig.getAddressesSettings();
if (map.size() == 0) {
AddressSettings as = new AddressSettings();
map.put("#", as);
}
Map.Entry<String, AddressSettings> entry = map.entrySet().iterator().next();
AddressSettings settings = entry.getValue();
settings.setAutoCreateQueues(true);
System.out.println("server cofg, isauto? " + entry.getValue().isAutoCreateQueues());
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class HangConsumerTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultInVMConfig().setMessageExpiryScanPeriod(10);
ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
server = addServer(new MyActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
server.start();
locator = createInVMNonHALocator();
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class HeuristicXATest method internalTest.
private void internalTest(final boolean isCommit) throws Exception {
Configuration configuration = createDefaultInVMConfig().setJMXManagementEnabled(true);
ActiveMQServer server = createServer(false, configuration);
server.setMBeanServer(mbeanServer);
server.start();
Xid xid = newXID();
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(true, false, false);
session.createQueue(ADDRESS, ADDRESS, true);
session.start(xid, XAResource.TMNOFLAGS);
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage msg = session.createMessage(true);
msg.getBodyBuffer().writeString(body);
producer.send(msg);
session.end(xid, XAResource.TMSUCCESS);
session.prepare(xid);
session.close();
ActiveMQServerControl jmxServer = ManagementControlHelper.createActiveMQServerControl(mbeanServer);
String[] preparedTransactions = jmxServer.listPreparedTransactions();
Assert.assertEquals(1, preparedTransactions.length);
System.out.println(preparedTransactions[0]);
Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
if (isCommit) {
jmxServer.commitPreparedTransaction(XidImpl.toBase64String(xid));
} else {
jmxServer.rollbackPreparedTransaction(XidImpl.toBase64String(xid));
}
Assert.assertEquals(0, jmxServer.listPreparedTransactions().length);
if (isCommit) {
Assert.assertEquals(1, jmxServer.listHeuristicCommittedTransactions().length);
Assert.assertEquals(0, jmxServer.listHeuristicRolledBackTransactions().length);
} else {
Assert.assertEquals(0, jmxServer.listHeuristicCommittedTransactions().length);
Assert.assertEquals(1, jmxServer.listHeuristicRolledBackTransactions().length);
}
if (isCommit) {
Assert.assertEquals(1, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable())));
session = sf.createSession(false, false, false);
session.start();
ClientConsumer consumer = session.createConsumer(ADDRESS);
msg = consumer.receive(1000);
Assert.assertNotNull(msg);
msg.acknowledge();
Assert.assertEquals(body, msg.getBodyBuffer().readString());
session.commit();
session.close();
}
Assert.assertEquals(0, getMessageCount(((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable())));
}
Aggregations