3 Replies Latest reply on Mar 26, 2015 6:45 AM by rakshukla

    jboss-ejb-client.xml vs. dynamic ejb receiver registration

    apakhunov

      I'm running jboss in standalone mode and I want to have an ability to call EJBs from other remote servers in standalone mode.

       

      Part of the procedure in described here https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance.

      In addition remote servers should have distinct name defined either in jboss-app.xml in ear or in standalone.xml. This distinct name should be provided to InitialContext during lookup.

      Discussed here https://community.jboss.org/thread/202268?start=0&tstart=0

       

       

      In order to add new connection to remote server instance, we need to describe connection in standalone.xml plus add corresponding remoting-ejb-receiver to jboss-ejb-client.xml in war/ear.

       

      One of the requirements for the app we develop is to have ability to add connections to remote servers at runtime (using web UI).

       

      Connection can be added dynamically at runtime without having to restart the server. We can use JBoss MAnagement API to achieve that.

       

      But in order to add remoting-ejb-receiver we will have to manually edit jboss-ejb-client.xml and repackage and redeploy war/ear.

       

      Is it possible to add remoting-ejb-receiver at runtime (e.g. using jboss-ejb-client api http://docs.jboss.org/ejbclient/1.0.5.Final/, using code similar to one in DescriptorBasedEJBClientContextService)?

        • 1. Re: jboss-ejb-client.xml vs. dynamic ejb receiver registration
          jaikiran

          Alexander Pakhunov wrote:

           

           

          Is it possible to add remoting-ejb-receiver at runtime (e.g. using jboss-ejb-client api http://docs.jboss.org/ejbclient/1.0.5.Final/, using code similar to one in DescriptorBasedEJBClientContextService)?

          Yes it is possible. Once you create the remoting connection (with the appropriate remoting APIs) within your application, you can register it as a receiver within the EJB client context as follows:

           

          // this will return the EJB client context that's applicable for your application
          final EJBClientContext ejbClientContext = EJBClientContext.requireCurrent();
          // let's assume you have create a connection dynamically. Let's now add it to the EJB client context so that it gets registered as a receiver
          ejbClientContext.registerConnection(connectionThatYouCreated);
          

           

          That's one way of doing it.

          • 2. Re: jboss-ejb-client.xml vs. dynamic ejb receiver registration
            apakhunov

            Thank you for your answer. It helped a lot, I made it work. I grabbed a piece of code from ConfigBasedEJBClientContextSelector.setupEJBReceivers to initialize connection and registered this connection in EJBClientContext.requireCurrent() as you suggested.

            • 3. Re: jboss-ejb-client.xml vs. dynamic ejb receiver registration
              rakshukla

              Could you please provide me pointers on how to create remoting connections from inside my  application ? Which are these remoting APIs that I can use to add remote-outboud-connections programmatically ?

               

              Thanks in advance.