2 Replies Latest reply on Apr 6, 2011 4:01 AM by laures

    How to overwrite the Activation Config for an MDB in the Deployment Descriptor?

    laures

      I developed a Message Driven bean that will now be used for multiple destinations. I want to define the Target Destination not by annotation (which would force me to change the code for each new destination) but in the deployment descriptor.

       

      In Java EE 6 definitions in the deployment descriptor should overwrite any values given in annotations. So in my case i created a an ejb-jar and configured my mdb. I thought this would overwrite the @MessageDriven annotation in the mdb-class. Unfortunately now two mdbs are deployed. one with the annotated configuration and one from the ejb-jar.

       

      I could easily remove the @MessageDriven annotation and stick with the descriptor, but i would like to keep the annotations as "default" values.

      Is there a way to reconfigure the annotations of my class?

       

      The mdb will run inside a jboss 6.

        • 1. How to overwrite the Activation Config for an MDB in the Deployment Descriptor?
          jaikiran

          What does the ejb-jar.xml and the MDB code look like? Are you sure you are using the same ejb-name in the message-driven element as the name that you have used for you annotated bean?

          • 2. Re: How to overwrite the Activation Config for an MDB in the Deployment Descriptor?
            laures

            Annotations for the MDB class:

             

            @MessageDriven(name = "HardwareTrackingConsumer",activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                    @ActivationConfigProperty(propertyName = "destination", propertyValue = "personal.laures.testing") })
            @ResourceAdapter("activemq-jms.rar")
            

             

            ejb-jar.xml :

             

            <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
                <enterprise-beans>
                    <message-driven>
                        <ejb-name>HardwareTrackingConsumer</ejb-name>
                        <ejb-class>test.AdvancedTrackingConsumer</ejb-class>
                        <activation-config>
                            <activation-config-property>
                                <activation-config-property-name>destinationType</activation-config-property-name>
                                <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
                            </activation-config-property>
                            <activation-config-property>
                                <activation-config-property-name>destination</activation-config-property-name>
                                <activation-config-property-value>personal.laures.hwtracking</activation-config-property-value>
                            </activation-config-property>
                        </activation-config>
                    </message-driven>
                </enterprise-beans>
            </ejb-jar>
            

             

            The javadoc for @MessageDriven sais that name defines the ejb-name so this should be right. But i get one consumer for the testing and one consumer for the hwtracking queue.

             

            The jboss log shows that two mdbs are deployed:

            09:55:24,267 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: test.AdvancedTrackingConsumer ejbName: HardwareTrackingConsumer

            09:55:24,299 INFO  [org.apache.activemq.ra.ActiveMQEndpointWorker] Starting

            09:55:24,301 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers

            09:55:24,304 INFO  [org.apache.activemq.ra.ActiveMQEndpointWorker] Establishing connection to broker [xxx:61616]

            09:55:24,311 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: test.AdvancedTrackingConsumer ejbName: HardwareTrackingConsumer

            09:55:24,313 INFO  [org.apache.activemq.ra.ActiveMQEndpointWorker] Starting

            09:55:24,313 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers

            Maybe its not important but the consumer is part of a .jar file inside an ear but the ejb-jar is inside the ear (so the config can be changed without repacking the jar)