8 Replies Latest reply on Dec 12, 2011 2:32 PM by frankie007

    Can I register ejb3 objects at runtime in AS 7.1?

    frankie007 Newbie

      Is there (or will there be) a way to create and register message-driven-beans and other ejb3 objects (like timers) at runtime in JBoss 7.1?

      So instead of registering a mdb programmatically or configuring and deploying it in the config, doing it at runtime by using an API or JBoss-dmr.

       

      I've noticed that the package ejb3-client has been added in 7.1, is it added for this purpose?

      Will JSR 77 be implemented in JBoss 7.1?

       

      Thanks in advance for any info on this.

        • 1. Re: Can I register ejb3 objects at runtime in AS 7.1?
          Sueleyman Vurucu Expert

          Hi frankie,

           

           

          you don't need register MDBs. The container do this work for you. You must configure your MDB by annotaion for your topic or queue.

          Timers aren't ejbs they are container serivces. All that stuff works allready if I'm not wrong. What not works is the lookup for JMS from outside the container.

           

          frankie007 schrieb:

           

           

          I've noticed that the package ejb3-client has been added in 7.1, is it added for this purpose?

          Will JSR 77 be implemented in JBoss 7.1?

           

          )

          AS 7.1.0 has the JEE6 Full Profile in Focus. So all the stuff muss work at the end .

           

          You can folow the opened issues here:

          https://issues.jboss.org/browse/AS7#selectedTab=com.atlassian.jira.plugin.system.project%3Aroadmap-panel

          • 2. Re: Can I register ejb3 objects at runtime in AS 7.1?
            frankie007 Newbie

            Thanks for the reply Sueleyman! Unfortunately this does not solve my problem.

             

            I know that I can register MDBs in the EJB container by using annotations at compile time.

            But I need to be able to register an MDB at runtime without needing to compile a class. Is this possible?

            Will the JSR 77 implementation in JBoss provide functionallity to do this? And if so, which mechanism should be used?

            Will I have to use JMX calls or will JBoss-dmr be extended to provide a wrapper around this?

             

            Forgive me if I'm asking stupid things. This is all quite new to me.

            • 3. Re: Can I register ejb3 objects at runtime in AS 7.1?
              Wolf-Dieter Fink Master

              I suppose you need a bit of business code to handle the message with an MDB.

               

              So I would say, deploy an application for each MDB/timer and deploy it during runtime. WIth AS7 you are able to disable such by management (console CLI or API).

               

              Other way is to deploy an application listening on a queue/topic and don't handle messages (but what to do? drop it?)

              Or deploy a timer and do some work or get messages from a queue based on a database configuration.

               

              But I think it will be a design that is not very good to understand Think about your requirements or even post it, maybe there are better ideas.

              • 4. Re: Can I register ejb3 objects at runtime in AS 7.1?
                Carlo de Wolf Master

                Maybe do it similar to how Arquillian does it, see CommonDeployableContainer.

                 

                The ArchiveDeployer goes through the ServerDeploymentManager which will communicate directly with the ModelController. You won't have to worry about jboss-dmr or the protocol and can just use ShrinkWrap archives.

                 

                Let us know how it goes.

                • 5. Re: Can I register ejb3 objects at runtime in AS 7.1?
                  frankie007 Newbie

                  Thanks for your replies guys!

                   

                  To make clear what I want to achieve, I'll elaborate a bit on our requirements. In our application the user must be able to create schedulers (timers) and message listeners (mdb) using a graphical developer tool. As a consequence we should be able to create and register these at runtime. I could off course try to generate the code (using annotations) and compile it at runtime, but I feel that this would be too complex. I hope there are better solutions.

                   

                  I like the idea of creating and deploying an application per mdb/timer, but I have a few questions on this:

                  • What would be the content of this application? Would it only contain an xml definition of the new mdb/timmer wrapped in an archive (ear)?
                  • If so, can't I just deploy the xml definition itself?
                  • If it is possible to deploy it like this is in JBoss, I suppose that the deployer itself can access an API to register the mdb in the ejb container? If so, can't I access this code directly?
                  • 6. Re: Can I register ejb3 objects at runtime in AS 7.1?
                    Carlo de Wolf Master

                    There is no a 'normal' API beneath (/beyond) the hood.

                     

                    You would need to create a DeploymentUnit and push it through the correct phases in the correct order as defined in Phase. Then the EJBComponentDescriptionFactory will pick it up and put new stuff on the DeploymentUnit for other Processors that come later (or in the next) Phase.

                    These will then fire up the correct MSC Services which make up the container and assocaited facilities (name space and such).

                    (The whole setup Processors is done from the subsystem OperationStepHandlers when the configuration is read.)

                     

                    Alternatively you could just create an XML in file (or String) and put in a ShrinkWrap Archive and throw that to the ServerDeploymentManager.

                    1 of 1 people found this helpful
                    • 7. Re: Can I register ejb3 objects at runtime in AS 7.1?
                      frankie007 Newbie

                      Thanks a lot Carlo!

                       

                      I'll try that last approach. I'll create an xml in memory, shrinkwrap it and deploy it using the JBoss management api.

                      I think that would be the least complex approach.

                      I'll let you know how this goes.

                      • 8. Re: Can I register ejb3 objects at runtime in AS 7.1?
                        frankie007 Newbie

                        After spending half a day on searching for the correct deployment descriptor for message-driven-beans I'm getting quite desperate.

                        I seems that all the documentation on how to replace annotations by deployment files in JBoss 7 still has to be written.

                         

                        Can someone point me the right direction?

                        Is there maybe some premature documentation available?

                         

                        Thanks a lot in advance!