Paging configuration
saeed87517 Mar 11, 2016 12:21 PMI am trying to enable paging mode in embedded server using following code. Maximum allowed memory set to 50MBs, but when I run the program, it uses more than 450MBs (for 200,000 messages) and the paging file size is zero! Is there anything I missed in paging configuration?
final String queueName = "queue.exampleQueue"; AddressSettings addressSettings = new AddressSettings(); addressSettings.setMaxSizeBytes(50 * 1024 * 1024); addressSettings.setPageSizeBytes(25 * 1024 * 1024); addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); final Map<String, AddressSettings> addressing = new HashMap<String, AddressSettings>(); addressing.put(queueName, addressSettings); Configuration configuration = new ConfigurationImpl(); configuration.setJournalDirectory("target/data/journal"); configuration.setPagingDirectory("target/data/paging"); configuration.setPersistenceEnabled(false); configuration.setSecurityEnabled(false); configuration.getAcceptorConfigurations() .add(new TransportConfiguration(InVMAcceptorFactory.class.getName())); configuration.setAddressesSettings(addressing); HornetQServer server = HornetQServers.newHornetQServer(configuration); server.start(); ServerLocator serverLocator = HornetQClient .createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())); ClientSessionFactory sf = serverLocator.createSessionFactory(); ClientSession coreSession = sf.createSession(false, false, false); coreSession.createQueue(queueName, queueName, true); coreSession.close(); ClientSession session = null; try { session = sf.createSession(); ClientProducer producer = session.createProducer(queueName); ClientMessage message = session.createMessage(false); final String propName = "myprop"; message.putStringProperty(propName, "Hello sent at " + new Date()); System.out.println("Sending the message."); for (int i = 0; i < 200000; i++) producer.send(message); ClientConsumer messageConsumer = session.createConsumer(queueName); session.start(); int counter = 0; ClientMessage messageReceived = messageConsumer.receiveImmediate(); while (messageReceived != null) { messageReceived.acknowledge(); counter++; messageReceived = messageConsumer.receiveImmediate(); } System.out.println(String.format("%d messages received!", counter)); } finally { if (sf != null) { sf.close(); } server.stop(); } catch (Exception e) { e.printStackTrace(); }