use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class LargeMessageTest method testPageOnLargeMessage.
protected void testPageOnLargeMessage(final boolean realFiles, final boolean sendBlocking) throws Exception {
Configuration config = createDefaultConfig(isNetty());
final int PAGE_MAX = 20 * 1024;
final int PAGE_SIZE = 10 * 1024;
HashMap<String, AddressSettings> map = new HashMap<>();
AddressSettings value = new AddressSettings();
map.put(ADDRESS.toString(), value);
ActiveMQServer server = createServer(realFiles, config, PAGE_SIZE, PAGE_MAX, map, storeType);
server.start();
final int numberOfBytes = 1024;
final int numberOfBytesBigMessage = 400000;
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
if (sendBlocking) {
sf.getServerLocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);
}
ClientSession session = sf.createSession(null, null, false, true, true, false, 0);
session.createQueue(ADDRESS, ADDRESS, null, true);
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = null;
for (int i = 0; i < 100; i++) {
message = session.createMessage(true);
// TODO: Why do I need to reset the writerIndex?
message.getBodyBuffer().writerIndex(0);
for (int j = 1; j <= numberOfBytes; j++) {
message.getBodyBuffer().writeInt(j);
}
producer.send(message);
}
ClientMessage clientFile = createLargeClientMessageStreaming(session, numberOfBytesBigMessage);
producer.send(clientFile);
session.close();
if (realFiles) {
server.stop();
server = createServer(true, config, PAGE_SIZE, PAGE_MAX, map, storeType);
server.start();
sf = createSessionFactory(locator);
}
session = sf.createSession(null, null, false, true, true, false, 0);
ClientConsumer consumer = session.createConsumer(ADDRESS);
session.start();
for (int i = 0; i < 100; i++) {
ClientMessage message2 = consumer.receive(LargeMessageTest.RECEIVE_WAIT_TIME);
Assert.assertNotNull(message2);
message2.acknowledge();
Assert.assertNotNull(message2);
message.getBodyBuffer().readerIndex(0);
for (int j = 1; j <= numberOfBytes; j++) {
Assert.assertEquals(j, message.getBodyBuffer().readInt());
}
}
consumer.close();
session.close();
session = sf.createSession(null, null, false, true, true, false, 0);
readMessage(session, ADDRESS, numberOfBytesBigMessage);
// printBuffer("message received : ", message2.getBody());
session.close();
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class MessageGroupingTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration configuration = createDefaultInVMConfig();
server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
server.start();
locator = createInVMNonHALocator();
clientSessionFactory = createSessionFactory(locator);
clientSession = addClientSession(clientSessionFactory.createSession(false, true, true));
clientSession.createQueue(qName, qName, null, false);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ConcurrentCreateDeleteProduceTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false).setJournalSyncTransactional(false);
server = createServer(true, config, PAGE_SIZE, PAGE_MAX, new HashMap<String, AddressSettings>());
server.start();
locator = createNonHALocator(false).setBlockOnDurableSend(false).setBlockOnAcknowledge(true);
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class ArtemisBrokerWrapper method start.
@Override
public void start() throws Exception {
clearDataRecreateServerDirs();
mbeanServer = MBeanServerFactory.createMBeanServer();
server = createServer(realStore, true);
server.setMBeanServer(mbeanServer);
server.getConfiguration().getAcceptorConfigurations().clear();
Configuration serverConfig = server.getConfiguration();
serverConfig.setJMXManagementEnabled(true);
Map<String, AddressSettings> addressSettingsMap = serverConfig.getAddressesSettings();
// do policy translation
PolicyMap policyMap = this.bservice.getDestinationPolicy();
if (policyMap != null) {
translatePolicyMap(serverConfig, policyMap);
}
String match = "#";
AddressSettings commonSettings = addressSettingsMap.get(match);
if (commonSettings == null) {
commonSettings = new AddressSettings();
addressSettingsMap.put(match, commonSettings);
}
SimpleString dla = new SimpleString("ActiveMQ.DLQ");
commonSettings.setDeadLetterAddress(dla);
commonSettings.setExpiryAddress(dla);
commonSettings.setAutoCreateQueues(true);
commonSettings.setAutoCreateAddresses(true);
if (bservice.extraConnectors.size() == 0) {
serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616");
}
for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {
addServerAcceptor(serverConfig, info);
}
serverConfig.setSecurityEnabled(enableSecurity);
if (enableSecurity) {
ActiveMQJAASSecurityManager sm = (ActiveMQJAASSecurityManager) server.getSecurityManager();
SecurityConfiguration securityConfig = sm.getConfiguration();
securityConfig.addRole("openwireSender", "sender");
securityConfig.addUser("openwireSender", "SeNdEr");
// sender cannot receive
Role senderRole = new Role("sender", true, false, false, false, true, true, false, false);
securityConfig.addRole("openwireReceiver", "receiver");
securityConfig.addUser("openwireReceiver", "ReCeIvEr");
// receiver cannot send
Role receiverRole = new Role("receiver", false, true, false, false, true, true, false, true);
securityConfig.addRole("openwireGuest", "guest");
securityConfig.addUser("openwireGuest", "GuEsT");
// guest cannot do anything
Role guestRole = new Role("guest", false, false, false, false, false, false, false, false);
securityConfig.addRole("openwireDestinationManager", "manager");
securityConfig.addUser("openwireDestinationManager", "DeStInAtIoN");
// manager can only manage
Role destRole = new Role("manager", false, false, false, false, true, true, false, false);
Map<String, Set<Role>> settings = server.getConfiguration().getSecurityRoles();
if (settings == null) {
settings = new HashMap<>();
server.getConfiguration().setSecurityRoles(settings);
}
Set<Role> anySet = settings.get("#");
if (anySet == null) {
anySet = new HashSet<>();
settings.put("#", anySet);
}
anySet.add(senderRole);
anySet.add(receiverRole);
anySet.add(guestRole);
anySet.add(destRole);
}
Set<TransportConfiguration> acceptors = serverConfig.getAcceptorConfigurations();
Iterator<TransportConfiguration> iter = acceptors.iterator();
while (iter.hasNext()) {
System.out.println("acceptor =>: " + iter.next());
}
jmsServer = new JMSServerManagerImpl(server);
InVMNamingContext namingContext = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
server.start();
stopped = false;
}
use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.
the class OpenwireArtemisBaseTest method createBroker.
public EmbeddedJMS createBroker() throws Exception {
Configuration config0 = createConfig(0);
EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
return newbroker;
}
Aggregations