2013-04-08 54 views
1

我们使用HornetQ核心API来从HornetQClient创建ServerLocator。 ServerLocator用于创建队列。 下面的代码:在HornetQClient中设置max-size-bytes和address-full-policy

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); 

的问题是,我们需要配置的最大尺寸字节和Te地址全政策,为每个队列。

我知道如何通过在XML中做到这一点,但由于我使用hornetq核心来配置队列,这些参数也需要通过代码进行配置。

我看到有一个叫AddressSettings类,这些参数可以设置

我的问题是 - 如何配置此AddressSettings对象到ServerLocator?

或者 - 在从HornetQCLient创建的ServerLocator中配置这些参数还有另一种方法吗?

回答

1

AddressSettings是服务器的属性,您不能从客户端进行设置。您可以在HornetQServer上使用它,或更改等效的XML。

AddressSettings基于通配符。因此,您可以创建一个地址设置,以便根据您的规则匹配您的队列名称。

如果您正在使用嵌入式服务器时,您可以使用此:

server.getAddressSettingsRepository().addMatch("<your-expression-matchin your queue(s)", setting); 

配置使用XML,看看文档的这一部分:

http://docs.jboss.org/hornetq/2.2.14.Final/user-manual/en/html/queue-attributes.html#queue-attributes.address-settings

在Jboss应用服务器7可以在standalone-all.xml(或任何包含hornetq /消息传递的独立* .xml)中找到相同的XML片段。

+0

我知道,因为我使用Horn etQCLient,我不能使用AddressSettings。但目前我没有使用任何XML来配置HornetQClient。我怎样才能添加这样的XML?这个XML应该放在哪里? – 2013-04-08 12:59:41

+0

(有帖子用你问我的信息编辑了答案) – 2013-04-08 14:27:02

相关问题