11 Replies Latest reply on Feb 16, 2011 11:06 PM by honeychen03

    How to use annotation to configure ejb3

    honeychen03

      as the title. Wanting to get rid of ejb-jar.xml, etc configuration files by using annotation for ejb3. Is there a doc link that I can visit? Much appreciated.

        • 1. How to use annotation to configure ejb3
          jaikiran

          The EJB3 tutorials here http://docs.jboss.org/ejb3/docs/tutorial/1.0.7/html/index.html have the examples. Depending on which configurations you want to move out of the ejb-jar.xml, you'll have to look at the appropriate chapter.

          1 of 1 people found this helpful
          • 2. How to use annotation to configure ejb3
            honeychen03

            I am trying to move the mdb configuration out of ejb-jar.xml and jboss.xml located in my ear. Can you give me more specific instruction doc about the mdb annotation configuration since it is a bit hard for me to search in the bunch of links?

            • 3. Re: How to use annotation to configure ejb3
              honeychen03

              I got this link (http://docs.jboss.org/ejb3/docs/tutorial/1.0.7/html/Message_Driven_Beans_with_deployment_descriptor.html) about the configuration of MDB but it describes how to configure it in xml. Is there an example about how to configure this by

              @ActivationConfigProperty

               

              detailedly

              • 4. How to use annotation to configure ejb3
                peterj

                JBoss in Action lists the valid ActivationConfigProperty properties that can be used for JBoss Messaging. There are several defined by the EJB3 spec so I suspect I got those from there. There are also several properties specific to JBoss Messaging but I don't know exactly where I got those from - could be one of the Messaging docs, but I can't find it there, or it could be the source code (since that is the definitive source).

                • 5. How to use annotation to configure ejb3
                  jpiel

                  First I use JBoss 5.1

                   

                  If you want to use simple MDBs I think it will work with an annotated configuration like this:

                   

                  @MessageDriven(name = "someName", activationConfig = {

                          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                          @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/someName")

                   

                  The first ActivationConfigProperty defines the kind of queue from where the MDB retrieves messages. The javax.jms.Queue works for me.

                  The second one defines the destination itselfs. You have to configure it in the \server\default\deploy\messaging\destinations-service.xml in a way like this:

                   

                  <mbean code="org.jboss.jms.server.destination.QueueService"

                        name="jboss.messaging.destination:service=Queue,name=someName"

                        xmbean-dd="xmdesc/Queue-xmbean.xml">

                        <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                        <depends>jboss.messaging:service=PostOffice</depends>

                     </mbean>

                   

                  Then you can look up the ConnectionFactory with the name queue/someName.

                   

                  I think that's all but I'm not using MDB very often.

                  1 of 1 people found this helpful
                  • 6. How to use annotation to configure ejb3
                    honeychen03

                    Thanks so much, jan. I have a question about how to configure the durability with the annotation. The old configuration in ejb-jar.xml is

                     

                    <subscription-durability>

                                                                      Durable

                                                            </subscription-durability>

                     

                    Do you know or anybody else has an idea about this?

                    • 7. How to use annotation to configure ejb3
                      jaikiran
                      • 8. How to use annotation to configure ejb3
                        honeychen03

                        Hi jaikiran,

                         

                        Could you please tell me which jar(s) is used for importing the @MessageDriven and @ActivationConfigProperty in JBoss 6.0.0.Final's library?

                         

                        Thanks.

                        • 9. How to use annotation to configure ejb3
                          jaikiran

                          JBOSS_HOME/client/jboss-ejb-api_3.1_spec.jar

                          • 10. How to use annotation to configure ejb3
                            honeychen03

                            One last question:

                            what is the annotation property for the old configuration below

                            <transaction-type>Bean/Container</transaction-type>

                            • 11. How to use annotation to configure ejb3
                              honeychen03

                              Is there any other things that I need to do?

                              I configured following in my MDB

                               

                              @MessageDriven(activationConfig =

                              {

                                      @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/com.globalsight.everest.jms.WorkflowAdditions"),

                                      @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                                      @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable")})

                               

                              and added below queue into hornetq-jms.xml

                              <queue name="WorkflowAdditions">

                                  <entry name="queue/com.globalsight.everest.jms.WorkflowAdditions"/>

                              </queue>

                               

                              JBoss started correctly but after jms sends the messge, the onMessage method does not receive the request. Note: I have removed original configuration for this MDB from ejb-jar.xml and jboss.xml.

                               

                              Please advise.