HornetQ embedded: is it possible to set swap options for dynamic add-ons?

I use HornetQ in the built-in configuration, and the configuration object itself is created programmatically. The application supports dynamic address creation.

I would like to be able to set certain parameters when creating new addresses: using a page file, maximum page file size, memory threshold for paging. According to the HornetQ documentation , this must be done for each address.

I tried updating my configuration object with the settings for the new address, but the server (which was already running) does not use these new settings.

Is there a way to tell the server about the settings for each address after it starts?

Alternatively, can I tell the server for an automatic page for all addresses before I start?

+3
source share
1 answer

found the answer shortly after posting: you can use the swap manager for the embedded server:

final AddressSettings addressSetting = new AddressSettings();
addressSetting.setMaxSizeBytes(10 * 1024 * 1024); // 10 MB
addressSetting.setPageSizeBytes(1024 * 1024);     // 1 MB

server.getPagingManager().getPageStore(new SimpleString(addressName))
                         .applySetting(addressSetting);

Alternatively, settings for all addresses can be set in the configuration object (based on this SO response ):

final Configuration hornetConfig = new ConfigurationImpl();
// other configuration...

final AddressSettings addressSetting = new AddressSettings();
addressSetting.setMaxSizeBytes(10 * 1024 * 1024); // 10 MB
addressSetting.setPageSizeBytes(1024 * 1024);     // 1 MB

final Map<String, AddressSettings> addressing = new HashMap<String, AddressSettings>();
addressing.put("#", addressSetting); // the # pattern matches all addresses
hornetConfig.setAddressesSettings(addressing);
+3
source

All Articles