How to make MDB Activation Spec contextual properties configurable?

喜欢而已 提交于 2019-12-11 00:16:07

问题


In our project, we are are using an MDB that listens for a message on a specific queue. It is defined as an annotation.

Example:

@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "20")})

.

In order to change the value of the maxSessions, the code has to be compiled everytime. Even if i configure it in ejb-jar.xml instead of as an annotation , i need to compile the code and generate EAR file.

Is there a way to make it user configurable(read from properties file) so that the recompilation of code is not required and by just changing the maxSession value to "30" and restarting the jboss, it should be working.

Kindly help.

Reference Code:

@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "ABCQueue"),
@ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "20"),    @ActivationConfigProperty(propertyName="maxMessagesPerSessions",propertyValue="15")})
public class ABCMDB implements MessageListener
{
   ----------- 
}

回答1:


I started to write a gist about Wildfly8 and Websphere MQ integration, allowing to configure and maintain environment contextual configuration for MDB or JMS messages producers.

Basically, I had to declare a jboss-ejb3.xml custom deployment descriptor in my application which use system properties for contextual configuration used by my MDB.

System-properties are configured in wildfly standalone-full.xml file, under system-properties element. So not in a property file, but to my view standalone-full.xml configuration is a good location for such configuration.

Here is the link : https://gist.github.com/remibantos/33c366803f189db9b225




回答2:


There is an easy way in Wildfly (I've used it for Wildfly 11).

  1. Enable property replacement in annotation by updating "ee" subsystem in standalon-xx.xml or domain.xml

<subsystem xmlns="urn:jboss:domain:ee:4.0"> ... <annotation-property-replacement>true</annotation-property-replacement> ... </subsystem>

  1. Define the System Properties, in standalon-xx.xml or domain.xml

    <system-properties>
    <property name="property.maxsessions" value="50"/> </system-properties>

Or your own properties file using -P myconfigured.properties , while starting wildfly

Or via command line while starting wildfly -Dproperty=value

  1. Modify MDB annotation

    @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "${property.maxsessions}")

Reference: https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/developing_ejb_applications/#message_driven_beans-1



来源:https://stackoverflow.com/questions/34030422/how-to-make-mdb-activation-spec-contextual-properties-configurable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!