Merged deployment

Edit
Update time: 2019-07-25

In Jarslink 2.0, merged deployment refers to loading and running multiple Biz packages in the same JVM. In the section Application Packaging, we have described the relationship between the Spring Boot/SOFABoot application and the Biz package. We may think that merged deployment here refers to loading and running multiple Spring Boot/SOFABoot applications in the same JVM.

It is mentioned at the end of Application Packaging that a Biz package can be released to a remote repository through the mvn deploy command, similar to releasing common Jar packages. It comes naturally to mind that the advantage of doing so is that the Biz package generated by other applications can be introduced in the form of dependencies, just like introducing common Jar package dependencies. Then, what is the purpose of introducing the Biz package generated by other applications into your application? Also, how do we dynamically install and uninstall Biz packages in Jarslink 2.0?

To answer the two questions above is to understand the concepts of static merged deployment and dynamic merged deployment.

Static merged deployment

To answer the first question: What is the purpose of introducing the Biz package generated by other applications into your application?

In the section Application Packaging, we have described how to package an application into an Ark package and offered a rough equation: Ark package = Biz package + SOFAArk framework + Ark Plugin. When a Biz package generated by other applications is introduced in the application, what kind of packaged Ark package will it be? The conclusion is that the packaging plugin will treat special dependency packages like the Biz package differently. The plugin will package all the non-Biz package dependencies into the application’s Biz package, but will consider the introduced Biz package as equal to those of the current application. The final Ark package will contain multiple Biz packages. For details, refer to Ark Package Directory Structure. At this point, when you use java -jar to start this Ark package, you will find that all the contained Biz packages will be started as well.

To sum up, the application introduces the Biz packages generated by other applications in the form of dependencies, and the Ark package packaged by this application will contain multiple Biz packages. By executing this Ark package, all the Biz packages will be started, known as static merged deployment.

Static merged deployment does not depend on Jarslink 2.0 but is available directly with the SOFAArk packaging plugin.

Note that the startup order of multiple Biz packages is controllable. When each Biz package is generated, you can use the packaging plugin to configure its priority, whose value is 100 by default. The higher the priority, the lower the value is. The priority determines the startup order of the Biz package.

Dynamic merged deployment

To answer the second question: how do you dynamically install and uninstall Biz packages in Jarslink 2.0?

Instead of static merged deployment, Jarslink2.0 enables the SOFAArk framework to dynamically install and uninstall the Biz package. If the Ark package contains the Jarslink2.0 plugin, Jarslink2.0 can receive dynamic commands to install or uninstall a Biz package. Currently, Jarslink2.0 only supports command interaction by way of the telnet protocol through port 1234. To access the interface of Jarslink2.0, start the Ark package and execute telnet ip 1234. We plan to introduce interaction through http requests in Version 0.2.0.

Detailed information about the command syntax of Jarslink2.0 is given in Jarslink Interactive Commands. Now, we will focus on how to use Jarslink2.0 to perform application hot updates. Hot update here means to switch an application from an older version to a newer one without suspending the services that the application is delivering.

Jarslink2.0 identifies a Biz package only by its name and version number during the merged deployment. The name and version number of a Biz package is generated during the plugin packaging and recorded in the MANIFEST.MF file. Jarslink2.0 allows simultaneous installation of several versions of Biz packages with the same name, but only one can deliver services at a time. The service here refers to the JVM service published by the Biz package. For detailed information about the JVM service, see Ark Biz Communications. When Jarslink2.0 has installed two different versions of Biz packages with the same name, you can send a command to switch the version that provides services. In this way, you can perform hot updates while ensuring service continuity.

Note that multiple web applications are not supported in either static merged deployment or dynamic merged deployment.