9 Replies Latest reply on Jan 29, 2013 10:12 AM by Dennis Buttery

    Synchronize initialization of services/actions

    Dennis Buttery Newbie

      Hi all,

       

        Wondering if there is a tried-n-true way to synchronize the service/action initialization process?

       

        Specifically, I am looking for a way to have all service/action initialization wait until one particular initialization takes place.

       

        To further complicate things this would need to occur across all services/actions of the ESB.

       

        Is there a higher-level initialization process that can be tapped into at the ESB level that would provide this behavior?

       

      Thanks,

      -Dennis

        • 1. Re: Synchronize initialization of services/actions
          Tom Cunningham Master

          There's the deployment.xml - you can have your ESB archive depend on an outside deployment.     Maybe have an mbean do the initialization that you are looking for and then list it in the deployment.xml?

           

          Or have a subclass for your actions that implements the initialize method?

          • 2. Re: Synchronize initialization of services/actions
            Dennis Buttery Newbie

            Tom,

             

                Thanks for responding.  Not quite what I was looking for though ...

             

                I have a single ESB that presents multiple services and each of those services may have multiple actions.  On deployment/startup, I'd like to have the services/actions 'wait' until one particular service/action has completed its initialization.  Once that initialization is complete then the others would be free to continue with their own startup process.

             

                Is there any way to do this?   Is it possible to impose an ordering or sequence to the initialization process?

             

            Thanks,

            -Dennis

            • 3. Re: Synchronize initialization of services/actions
              Tom Cunningham Master

              Dennis,

               

              There's probably not going to be an exactly perfect option here, but there's plenty of options you can choose from.     You could separate the one particular service from your .ESB archive, and depend upon the deployment of that archive in your deployment.xml.        You could look at the service pipeline interceptors which were added in ESB 4.11 - if you set it up for service instantiation, it will run at every service instantiation.    You would have to have some guard around whatever code you wanted to run there to make sure it only executes one time.

               

              --Tom

              • 4. Re: Synchronize initialization of services/actions
                Dennis Buttery Newbie

                Tom,

                 

                    I was able to move my controlling service to its own ESB and then have my second ESB depend on the first using the deployment.xml.

                 

                    Seems to work fine.    Thanks!

                 

                -Dennis

                • 5. Re: Synchronize initialization of services/actions
                  Dennis Buttery Newbie

                  Maybe spoke too soon here ...

                   

                  Tom - can you shed some light on a behavior issue?

                   

                  I have ESB-A and ESB-B.   ESB-B has a dependancy on ESB-A.    ESB-A, on initialization, runs a chunk of setup code that may take some amount of time to complete.

                   

                  Here is the initialization sequence that I am seeing ...

                   

                  1)  ESB-A initializes and runs the setup code and successfully completes.

                   

                  A few seconds later ...

                   

                  2)   JBoss undeploys ESB-A.   ???

                   

                  3)  ESB-B then starts to initialize (Queues created, etc...)

                   

                  4)  ESB-A is then (re)deployed and initialization code runs again.  ???

                   

                  5)  Once ESB-A finishes its initialization (again) then ESB-B runs its initialization code and completes successfully.

                   

                  So...  Why is ESB-A undeployed and then redeployed when ESB-B deployment starts?

                   

                  Thanks,

                  -Dennis

                  • 6. Re: Synchronize initialization of services/actions
                    Tom Cunningham Master

                    What happens in the initialization code?      Are you touching any files within the deployment?

                    • 7. Re: Synchronize initialization of services/actions
                      Dennis Buttery Newbie

                      At the moment, nothing much happens in the init code.  This is in the beginning stages of development and I'm dealing with it as a POC for now.  The intent of ESB-A will be to maintain a database.  Currently, It only instantiates its DataSource via JNDI.   ESB-B is only stubbed right now and only writes to the log.

                      • 8. Re: Synchronize initialization of services/actions
                        Tom Cunningham Master

                        Can you post the log that shows the init sequence?      I'm confused by why ESB-A would undeploy, unless the initialization code is changing something within ESB-A and forcing a hot deployment.

                        • 9. Re: Synchronize initialization of services/actions
                          Dennis Buttery Newbie

                          Sorry for the response delay...   I was pulled onto another project for awhile.

                           

                          I think I may better understand what is happening here. 

                           

                          My ESBs are sharing a common connection factory definition.  Each of the ESBs also have a dependancy on the CF declared in their deployment.xml.

                           

                          When one ESB redeploys, the CF is unbound.  This causes all of the other ESBs to shutdown due to the missing CF dependancy.  As the first ESB initializes the CF is bound again and the remaining ESBs also startup and reinitialize.

                           

                          So...   Is there a way for ESBs to share a common CF but not incur this initialization ping-pong effect?  Is there a way to allow an ESB to shutdown/restart without having the CF unbound (since other ESBs are using it)?

                           

                           

                          Thanks,

                          -Dennis