Jms 在部署时生成客户端ID

Jms 在部署时生成客户端ID,jms,wildfly-8,hornetq,message-driven-bean,Jms,Wildfly 8,Hornetq,Message Driven Bean,我有一个WildFly群集,它应该将所有主题消息共享给不同的节点,并在一个节点脱机时保留这些消息。 对于这种情况,我需要耐用的订户 @MessageDriven( activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty(prope

我有一个WildFly群集,它应该将所有主题消息共享给不同的节点,并在一个节点脱机时保留这些消息。
对于这种情况,我需要耐用的订户

@MessageDriven(
    activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/Topic"),
        @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
        @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "anam123e"),
        @ActivationConfigProperty(propertyName = "clientID", propertyValue = "abcd"),
    }
)
我注意到,如果我使用的是同一个clientID,那么系统正在进行负载平衡。如果我将clientIDsubscriptionName更改为唯一的值,它将起作用

因此,何时使用唯一的客户端ID以及何时订阅名称
我的答案是,每个节点的唯一clientID和节点上每个线程的subscriptionName

此外,我希望基于wildfly节点名生成一个clientID,类似于:

@ActivationConfigProperty(propertyName = "clientID", propertyValue = "abcd-" + WildFly.getInstance().getNodeName()),

有什么方法可以实现吗?

有一个真正简单的解决方案:

您需要在standalone.xml中启用它:


有一个真正简单的解决方案:

您需要在standalone.xml中启用它:

<subsystem xmlns="urn:jboss:domain:ee:2.0">
    <annotation-property-replacement>true</annotation-property-replacement>
    ...
</subsystem>
@MessageDriven(
    activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/Topic"),
        @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
        @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "aname"),
        @ActivationConfigProperty(propertyName = "clientID", propertyValue = "abcd-${jboss.node.name}"),
    }
)