【问题标题】:Generate Client ID on deploy在部署时生成客户端 ID
【发布时间】:2015-10-03 01:10:15
【问题描述】:

我有一个 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 更改为唯一值,它会起作用。

那么什么时候使用唯一的clientID,什么时候使用subscriptionName
我的回答是,每个节点的唯一客户端 ID 和节点上每个线程的订阅名称。

此外,我想根据 Wildfly 节点名称生成一个 clientID,类似于:

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

有办法实现吗?

【问题讨论】:

    标签: jms wildfly-8 hornetq message-driven-bean


    【解决方案1】:

    有一个真正简单的解决方案可用:Property Replacement

    您需要在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}"),
        }
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-14
      • 2010-09-19
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多