7 Replies Latest reply on Oct 31, 2013 5:47 AM by mageshbk

    Deploy order of sub-dependencies in ear-bundled SY applications

    jachym.culka

      Hello, I'm currently working on a project where we deploy several SY application (10+) as a single EAR package, which works great. Now we would like to introduce dependencies among SY applications, simply to start one particular SY as the last. I tired to state such dependencies in jboss-deployment-structure which, according to AS 7.x documentation, but wasn't lucky, SY modules were deployed in random order which I tested by grepping server logs for "org.switchyard.deploy.internal.Deployment ... Initializing deployment".

      BTW, I also tired to enable deploying in order as written in application.xml by <initialize-in-order>true</initialize-in-order> with the same result.

       

      I wrote very simple test that can be used to test that behavior (ear attached) which I deployed several times with following results;

       

      13:21:29,173 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-13) Initializing deployment {http://test.com/ApplicationA}EarSYTest

      13:21:29,183 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-5) Initializing deployment {http://test.com/ApplicationC}EarSYTest

      13:21:29,186 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-6) Initializing deployment {http://test.com/ApplicationB}EarSYTest

       

      13:21:50,134 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-11) Initializing deployment {http://test.com/ApplicationC}EarSYTest

      13:21:50,139 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-2) Initializing deployment {http://test.com/ApplicationA}EarSYTest

      13:21:50,140 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-14) Initializing deployment {http://test.com/ApplicationB}EarSYTest

       

      13:24:34,379 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-5) Initializing deployment {http://test.com/ApplicationB}EarSYTest

      13:24:34,382 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-6) Initializing deployment {http://test.com/ApplicationC}EarSYTest

      13:24:34,389 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-11) Initializing deployment {http://test.com/ApplicationA}EarSYTest

       

      As you can see, order of deployments seems to be completely random. These are very trivial (only SY descriptor with empty composite el) SY apps but the behavior is the same as with our real applications which deploys not in several ms but in tens of seconds.

      Edit: Forgot to mention this, expected result would be A starting always after B, C, as A has dependencies on them.

       

      My question is therefore following, is it possible to anyhow enforce order of sub-deployment SY applications in ear package, and if so, how it's done?

       

      Tested on SY 0.8 in EAP 6.1 (SOA 6 Alpha 1).

       

      Thanks in advance

      Jachym

        • 1. Re: Deploy order of sub-dependencies in ear-bundled SY applications
          kcbabo

          I haven't had a chance to look at this yet, but I would expect this to work, so it's definitely something we need to look at.  Thanks for the level of detail and the example app to reproduce the issue.  We will get back to you soon.  I can tell you the first thing I'm going to try is running this in 1.0.0.Final, so if you want to beat me to the punch there, feel free. :-)

          • 2. Re: Re: Deploy order of sub-dependencies in ear-bundled SY applications
            jachym.culka

            Ok, seems like I've won this round , I did retest on SY 1.0.0.Final with slightly altered test application (attached) (now each sy app contains single bean service which takes 5s seconds to initialize (thread sleep in constructor)). Outcome is the same. See following log snippet;

             

            ...

            16:48:34,141 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-13) Starting deployment {http://test.com/ApplicationA}EarSYTest

            16:48:34,141 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-14) Starting deployment {http://test.com/ApplicationC}EarSYTest

            16:48:34,141 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-3) Starting deployment {http://test.com/ApplicationB}EarSYTest

            ...

            16:48:39,149 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-13) Deploying service bindings for deployment {http://test.com/ApplicationA}EarSYTest

            16:48:39,149 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-3) Deploying service bindings for deployment {http://test.com/ApplicationB}EarSYTest

            16:48:39,149 DEBUG [org.switchyard.deploy.internal.Deployment] (MSC service thread 1-14) Deploying service bindings for deployment {http://test.com/ApplicationC}EarSYTest

            ...

            • 3. Re: Deploy order of sub-dependencies in ear-bundled SY applications
              mageshbk

              The jboss-deployment-structure.xml is for configuring classloader dependencies and not for the order of deployments. If you need to order multiple deployments when they are deployed simultaneously then you need to use jboss-all.xml An example would be as below for A.jar

              <jboss umlns="urn:jboss:1.0">
                <jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
                <dependency name="C.jar" />
                <dependency name="B.jar" />
                </jboss-deployment-dependencies>
              </jboss>
              

               

              Now back to your original question of ordering deployments within a EAR. According to the Java EE 6 specification EE.8.5.4 (Module Initialization) a java module is an "application client module" and the order in which they are initialized is unpredictable. The initialize-in-order works, as long as you use ejb or war components as they are server modules. Try this application.xml and your deployment will be in the order specified

              <?xml version="1.0" encoding="UTF-8"?>
              <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
                <initialize-in-order>true</initialize-in-order> 
                <module>
                  <ejb>B.jar</ejb>
                </module>
                <module>
                  <ejb>C.jar</ejb>
                </module>
                <module>
                  <ejb>A.jar</ejb>
                </module>
                <library-directory></library-directory>
              </application>
              

               

              Note, I have changed all java modules to ejb.

              • 4. Re: Deploy order of sub-dependencies in ear-bundled SY applications
                jachym.culka

                Hi, I tried to deploy the same ejb with the changes to application.xml as you posted above with no success. And by that I mean that all switchyard services were deployed at once (roughly after 5s as all services take 5s to initialize but I'd expect that deployment of the whole ear would take slightly more than 15s), the class dependencies might work but I expect that the dependency config would work for services too, that is after all services in switchyard ear subdeployments B and C are deployed, deployment of A can be started. Currently even after the change you recommended the outcome is the same as in my first reply.

                • 5. Re: Deploy order of sub-dependencies in ear-bundled SY applications
                  mageshbk

                  Ah! I did not notice your reply with another app. I understand that your concern is even thought the order of initialization works as specified in the application.xml, the deployments are not fully finished before starting another one. Is that right? I will have to test and see if a real ejb/war behaves the same way. Meaning, that it could it be an inherent problem because AS7 deploys apps in parallel? Give me some time to investigate and isolate the issue.

                   

                  regards,

                  Magesh

                  • 6. Re: Deploy order of sub-dependencies in ear-bundled SY applications
                    jachym.culka

                    That's precisely the problem we are trying to solve, thanks for your help.

                    • 7. Re: Deploy order of sub-dependencies in ear-bundled SY applications
                      mageshbk

                      As you know SwitchYard is not an EE component. But nevertheless, we can support the initialize-in-order flag. I have opened a JIRA to give you that feature. Please vote and watch for the same.

                       

                      [SWITCHYARD-1799] Add support for initialize in order for ear deployments - JBoss Issue Tracker