我们正在使用HornetQ核心API来从HornetQClient创建ServerLocator。 ServerLocator用于创建队列。 这是代码:
TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(connectorConfig);
int ackBatchSize = ConfigWrapperHelper.getIntParameter(ProductMarkingConfigParamEnum.ACK_BATCH_SIZE_FOR_JMS_QUEUES);
locator.setAckBatchSize(ackBatchSize);
locator.setConsumerWindowSize(CONSUMER_WINDOW_SIZE);
locator.setClientFailureCheckPeriod(Long.MAX_VALUE);
locator.setConnectionTTL(-1);
ClientSessionFactory clientSessionFactory = locator.createSessionFactory(connectorConfig);
ClientSession clientSession = _clientSessionFactory.createSession(XA, AUTO_COMMIT_SENDS, AUTO_COMMIT_ACKS);
clientSession.createQueue(queueName, queueName, IS_DURABLE);
问题是我们需要为每个队列配置max-size-bytes和te address-full-policy。
我知道如何通过XML实现这一点,但由于我使用hornetq核心来配置队列,因此这些参数也需要通过代码进行配置。
我看到有一个名为AddressSettings的类,可以设置这些参数。
我的问题是 - 如何将此AddressSettings对象配置到ServerLocator中?
或者 - 是否有另一种方法在从HornetQCLient创建的ServerLocator中配置这些参数?
答案 0 :(得分:2)
AddressSettings是服务器的属性,您无法从客户端设置它。您可以在HornetQServer上使用它,也可以更改等效的XML。
AddressSettings基于通配符。因此,您可以根据规则创建一个与队列名称相匹配的地址设置。
如果您使用的是嵌入式服务器,可以使用:
server.getAddressSettingsRepository().addMatch("<your-expression-matchin your queue(s)", setting);
要使用XML进行配置,请查看文档的这一部分:
在JBoss 7上,可以在standalone-all.xml(或任何包含hornetq / messaging的独立* .xml)中找到相同的XML片段。