更改部署时读取 MDB 的主题的激活配置
我感觉这应该很容易。只需 RTM 即可开始。但我找不到我需要的信息。
问:我可以在部署时更改 @ActivationConfigProperty
的值,而无需编写任何 XML 吗?
更多详细信息
我有一个使用 @MessageDriven
注释的 MDB。其中有许多配置它的@ActivationConfigProperty
注释。
@MessageDriven(mappedName = "jms/TestJeremyTopic ", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "TopicReaderBeanClientId"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "TopicReaderBeanSubscriptionName")
})
public class TopicReaderBean implements MessageListener { // ...
我需要多次部署此 MDB,每次都引用不同的主题。
在部署时(WebSphere 7 ND),我能够为每个 EAR 配置不同的 TopicListenerPort
(WebSphere 映射到不同主题的方式)。但是,当我尝试启动第二个实例时,它失败并出现错误:
WMSG0019E:无法启动 MDB 侦听器 TopicReaderBean,JMSDestination jms/MMiSInLonTopic:com.ibm.msg.client.jms.DetailedIllegalStateException:JMSWMQ0026:无法使用 MQSUB 订阅主题“MMIS_LON_IN”。由于另一个消息使用者正在使用该订阅,因此创建订阅时可能出现问题。在尝试以相同名称创建新订阅之前,请确保所有使用此订阅的消息使用者都已关闭。请参阅链接的异常以获取更多信息。 原因为:com.ibm.mq.MQException:JMSCMQ0001:WebSphere MQ 调用失败,代码为“2”(“MQCC_FAILED”),原因为“2429”(“MQRC_SUBSCRIPTION_IN_USE”)。
当我查看 MQ Explorer 时,我可以看到订阅名称为 JMS:GGWKNNG5:gmm_poc_06:TopicReaderBeanSubscriptionName
这是由“JMS”、QueueManager 名称、主题连接工厂 ID 和 ActivationConfigProperty“subscriptionName”组成。由于此订阅名称冲突,第二个连接失败。我需要区分不同 MDB 实例使用的订阅名称。
虽然我可以为每个 bean 创建一个新的主题连接工厂,但这需要大量工作并且没有多大意义。
有意义的是每个 bean 有一个不同的订阅名称。然而,这个属性被嵌入到注释中,我在 WebSphere 中看不到任何允许我覆盖它的地方。
那么,我可以重写这个属性而无需编写 XML 部署描述符吗?如果我确实需要编写一些XML,我如何覆盖其中的属性?
I feel this should be easy. Just RTM and go. But I can't find the info I need.
Q: Can I change the value of an @ActivationConfigProperty
at deploy time without having to write any XML?
More detail
I have an MDB which is using the @MessageDriven
annotation. Within this are a number of @ActivationConfigProperty
annotations configuring it.
@MessageDriven(mappedName = "jms/TestJeremyTopic ", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "TopicReaderBeanClientId"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "TopicReaderBeanSubscriptionName")
})
public class TopicReaderBean implements MessageListener { // ...
I need to deploy this MDB multiple times, referring to a different topic each time.
At deploy time (WebSphere 7 ND) I am able to configure a distinct TopicListenerPort
(WebSphere's way of mapping to different topics) for each EAR. However when I try to start a second instance it fails with the error:
WMSG0019E: Unable to start MDB Listener TopicReaderBean, JMSDestination jms/MMiSInLonTopic : com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0026: Failed to subscribe to topic 'MMIS_LON_IN' using MQSUB. There may have been a problem creating the subscription due to it being used by another message consumer. Make sure any message consumers using this subscription are closed before trying to create a new subscription under the same name. Please see the linked exception for more information.
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2429' ('MQRC_SUBSCRIPTION_IN_USE').
When I look to MQ Explorer I can see the subscription name is JMS:GGWKNNG5:gmm_poc_06:TopicReaderBeanSubscriptionName
This is a composition of "JMS", QueueManager name, Topic Connection Factory ID, and ActivationConfigProperty "subscriptionName". The second connection fails because of a clash on this subscription name. I need to distinguish the subscription names used by distinct MDB instances.
Whilst I could create a new Topic Connection Factory for each bean, it would be a lot of work and doesn't make much sense.
What does make sense is to have a different subscription name per bean. However this property is baked into the annotation and I can't see anywhere in WebSphere that would allow me to override it.
So, can I override this property without having to write an XML deployment descriptor? And if I do need to write some XML, how do I override the property therein?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我编写了一个可以在构建时修改的
ejb-jar.xml
配置来代替任何部署时解决方案。其内容如下:In lieu of any deploy-time solution I've written an
ejb-jar.xml
config that I can modify at build time. It reads thus: