Developing an ESB Deployment Package

This part will introduce you to the development of an ESB Deployment Package using the maven plugin.

Project Layout

We advise you to look at existing ESB Deployment Packages on int-factory in the SonicPartnerCodeshare/Projects location. These projects can offer an initial guidance to start.

You can also create Arche-Types for your developers. However, this will not be handled in this users-guide.

As depicted in the image, the plugin is working with a standard maven layout. The important locations are:

  1. src/main/sonicesb: Location for the ESB Artifacts (esbstyp file)
  2. src/test: For your test resources
  3. src/site: Location to define your site documentation

How-to Develop using the Plugin

The Maven-Plugin for ESB Deployment Packages takes a couple of files:

Model.xml

The Model.xml file contains all needed information to create a successfull deployment package. All variables are externalized using the @Variable@ pattern. The plugin will recognize these variables and extract them in the Topology tailoring file.

The plugin will also add some items to the Model.xml file:

  1. The Plugin will use queues.snippets in order to include used queues in your model. There is a way to have more control over the queue creation but that will be handled further down this page.
  2. The Plugin will walk down all the dependencies and take the ESB ones in order to import the XAR file using the model.xml.
  3. By default, the plugin also creates an ESB Container to hold all the service instances it encounters in the dependencies. There is a way to have more fine-grained control over the creation of containers that will be handle further down this page.
  4. The Plugin will detect the include pattern for ESB Containers. This is needed in order to include ESB Containers in certain segments without the need for the default include syntax. This is performed using the following Syntax where mfesbcontainer/ is the key that is searched and the second part the name of the container as defined in the containerproperties.xml file:
      <xi:include href="mfesbcontainer/@MFContainerName2@"/>

ContainerProperties.xml

One of the most common configuration tasks is to define the container mapping for an SDM model. Therefore the ContainerProperties.xml file needs to be tailored to the deployment needs.

The location of the file is: src/main/sonicesb/ContainerProperties.xml.

The format of this file is as follows:

<configuration>
        <containerMap>
                <esbContainerSettings> ... </esbContainerSettings> 
                <mfContainerSettings> ... </mfContainerSettings> 
        </containerMap>
</configuration>

This mapping will defines in which ESB container(s) a service instance will be deployed. By default all service instances will be deployed to the default ESBContainer (name=ESBContainer). If a service/process instance is selected by a dedicated container pattern it is removed from the default container. An instances can be added to multiple dedicated containers.

Note: The name DefaultContainer in the configuration is just the name of the Java class which implements the mapping and has no further meaning.

The ContainerMap element can contain the following sub-elements:

  • useESBDefaultIncludes - Whether or not (true/false) to place unmatched instances and processes in the default ESB container. Default: true
  • useMFDefaultIncludes - Whether or not (true/false) to place unmatched ESB containers in the default MF container. Default: true
  • esbContainerSettings - Settings for mapping service instances and processes to ESB containers
  • mfContainerSettings - Settings for mapping ESB containers to MF containers

    Setting useESBDefaultIncludes to false can be useful when you want to import service instances or processes into the domain but you don't want to create an ESB container for them.

    Setting useMFDefaultIncludes to false can be useful when you want to import ESB containers into the domain but you don't want to create an MF container for them.

The DefaultContainerSetting has the following Elements that can be set in order to change the ESB Container Configuration:

  • name: The Name of the ESB Container (Mandatory)
  • busConnection: The name of the Default JMS Connection for the Container (Optional)
  • routingHttpConnection: The name of the Default HTTP Connection for the Container (Optional)
  • enablePayloadCapture: If set to true it will enable the payload capture for Actional (Optional)
  • useForLookingGlass: If set to true, it will enable the Interceptor For the Container (Optional)
  • useIntraContainerMessaging: If set to true, this will enable the Intra-Container messaging flag (Optional)

An mapping example can be found below. All pattern elements support regular expression patterns.

The esbContainerSettings/DefaultContainerSetting/includes/DefaultIncludePattern supports the following includeProperties:

  • classpathPattern
    • regular expression to match JARs which should be put on the classpath. By default that classpath consists of the jar files that occur in the dependency directory, but are not referenced in the service types of the dependent xar archives. We will only add those jar files to the classpath that match a given regular expression.
    • default value: .*
  • classpathPatternEx
    • regular expression to match JARs which should be put on the classpath. This pattern allows the inclusion of jar files already referenced in the service types of the dependent xar archives. We will only add those jar files to the classpath that match a given regular expression.
    • default value: ^$
  • classpathSortPatter
    • multiple regular expression to match JAR names. The individual regular expressions are separeted using ; (semicolon). The JARs in the classptha will be sorted based on the regular expressions. All JAR files not selected by a pattern are added to the end of the sorted classpath.
    • default value: null
  • classpathOverride
    • This literal string is overriding any other ESB Container Classpath setting that would be configured in the classpath settings above.
    • default value: null
  • instances
    • Number of service instance
    • default value: 1
    • startupPriorityLevel
      • Priority level for the Services in order to control startup order
      • Default Value: 0
    • ConcurrentCalls
      • New feature that limits the number of listeners you need to define if ICM is used
      • Default Value: 0

The mfContainerSettings/DefaultContainerSetting supports the following extra settings:

  • backupContainer: The name of the backup container (Optional). Automatically clones components to the backup container.
  • bootContainer: Whether to install this container as a boot container. SDM will start bootcontainers after installation and optionally registers Windows services for them.
  • clone: This property is linked to the backupContainer property in order to indicate to SDM that the container is a clone or not.
  • Segment: This is an optional place to define the location of the MF Container to be created into the DS. This creates a Segment Tag when present.
  • ContainerParameterSet: This is an optional place to define the ContainerParameterSet to be used for this deployed instance
  • LogDirectory: This is an optional place to define the container log directory
  • In the mfContainerSettings section for each includePattern, you can add the (Logical)Hosts as a comma separated list in combination with the AutoStart property. Please consult the snippet below
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <containerMap>
            <esbContainerSettings>
                <DefaultContainerSetting>
                    <!-- ESB Container name-->
                    <name>ctESBsvn2hudson</name>
                    <busConnection>gfo-jms</busConnection>
                                <routingHttpConnection>gfo-jms</routingHttpConnection>
                    <enablePayloadCapture>true</enablePayloadCapture>
                    <useForLookingGlass>true</useForLookingGlass>
                    <useIntraContainerMessaging>true</useIntraContainerMessaging>
                    <includes>
                        <DefaultIncludePattern>
                            <!-- matched against the service instance info attribute. See snippets -->
                            <pattern>.*</pattern>
                            <includeProperties>
                                <property>
                                    <!-- classpath pattern for the ESB Container -->
                                    <name>classpathPattern</name>
                                    <!-- regex to match nothing, to have no additional jars on the classpath -->
                                    <value>#</value>
                                </property>
                                <property>
                                    <name>instances</name>
                                    <!-- Number of service instances -->
                                    <value>5</value>
                                </property>
                                <property>
                                    <name>startupPriorityLevel</name>
                                    <value>2</value>
                                </property>
                                <property>
                                    <name>ConcurrentCalls</name>
                                    <value>0</value>
                                </property>
                            </includeProperties>
                        </DefaultIncludePattern>
                    </includes>
                </DefaultContainerSetting>
            </esbContainerSettings>
            <mfContainerSettings>
                <DefaultContainerSetting>
                    <name>@MFESBContainer@</name>
                    <includes>
                        <DefaultIncludePattern>
                            <pattern>ctESBsvn2hudson</pattern>
                            <includeProperties>
                                <property>
                                    <name>Hosts</name>
                                    <value>ESBHost,MyMachine</value>
                                </property>
                                <property>
                                    <name>AutoStart</name>
                                    <value>true</value>
                                </property>
                            </includeProperties>
                        </DefaultIncludePattern>
                    </includes>
                    <backupContainer>@MFESBContainer@BAK</backupContainer>
                    <clone>true</clone>
                    <bootContainer>false</bootContainer>
                    <Segment>OurESBContainers</Segment>
                    <ContainerParameterSet>MyContainerParameterSet</ContainerParameterSet>
                                    <LogDirectory>MyLogDirectoryValue</LogDirectory>
                </DefaultContainerSetting>
                </mfContainerSettings>
        </containerMap>
    </configuration>

QueuMappings.xml

By default, queues are assigned to the last Queues element in the SDM Model.xml file. If you want to change this behavior you can create a file called QueueMappings.xml in the src/main/sonicesb directory. The contents of this file should be as follows:

<queueMappings>

        <defaultMapping>
                <id>defaultQueuesElement</id>
                <parameterSet>defaultQueue</parameterSet>
                <suppressJNDI>true</suppressJNDI>
        </defaultMapping>

        <queueMapping>
                <id>applicationABCQueues</id>
                <parameterSet>applicationEntryQueue</parameterSet>
                <suppressJNDI>false</suppressJNDI>
                <includes>
                        <include>.*entry$</include>
                </includes>
        </queueMapping>
                
        <queueMapping>
                <id>applicationABCQueues</id>
                <includes>
                        <include>(applicationa|applicationb)\..*</include>
                        <include>applicationc\..*</include>
                </includes>
                <excludes>
                        <exclude>applicationd.*</exclude>
                </excludes>
        </queueMapping>
                        
</queueMappings>

Note: The parameter suppressJNDI is valid only for SDM version 7.6.x or below. From version 8.0 the JNDI generation has changed, and this parameter is no longer valid

This will cause the Queues to be assigned to the queue element that matches any include regular expression but none of the optional exclude regular expressions. The first mapping that matches a queue get the queue assigned. If no mappings match the queue, it will be assigned to the queues element mentioned in the defaultMapping setting.

includes are required in the queueMapping element, excludes are optional. Neither may appear in the defaultMapping element. When there is no defaultMapping element, the last Queues element in Model.xml becomes the default. You can set the defaultMapping to a non-existent Queues element to force explicit definitions for all queues in the SDM model. The build will fail when the Queues element for a certain queue does not already exist.

Pom file content

Artifact Definition

        <groupId>your.group.id</groupId>
        <artifactId>artifactId</artifactId>
        <version>1.0-SNAPSHOT</version>
        <name>Short Name</name>
        <packaging>sdm</packaging>
        <description>Small description of what this Process is doing</description>
        <url>http://Servcer/location-to-doc/${project.groupId}/${project.artifactId}/${project.version}</url>

Build Section

        <build>
                <resources>
                        <resource>
                                <directory>src/main/resources</directory>
                                <filtering>true</filtering>
                        </resource>
                </resources>
                <plugins>
                        <!-- Assemble all dependencies with repository layout -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-site-plugin</artifactId>
                                <version>3.2</version>
                                <configuration>
                                        <reportPlugins>
                                                <plugin>
                                                        <groupId>org.apache.maven.plugins</groupId>
                                                        <artifactId>maven-project-info-reports-plugin</artifactId>
                                                        <version>2.6</version>
                                                        <!-- <configuration> <dependencyDetailsEnabled>false</dependencyDetailsEnabled> 
                                                                <dependencyLocationsEnabled>false</dependencyLocationsEnabled> </configuration> -->
                                                        <!-- simpler configuration without reportSets available for usual 
                                                                cases -->
                                                        <!-- <reports> <report>dependencies</report> <report>scm</report> 
                                                                </reports> -->
                                                </plugin>
                                                <plugin>
                                                        <groupId>org.codehaus.mojo</groupId>
                                                        <artifactId>jdepend-maven-plugin</artifactId>
                                                </plugin>
                                        </reportPlugins>
                                </configuration>
                        </plugin>
                        <plugin>
                                <groupId>com.aurea.maven.plugins</groupId>
                                <artifactId>sonicesb-maven-plugin</artifactId>
                                <version>${maven-sonicesb-plugin.version}</version>
                                <extensions>true</extensions>
                                <configuration>
                                        <containerMap>
                                                <esbContainerSettings>
                                                        <DefaultContainerSetting>
                                                                <name>ESBContainer</name>
                                                        </DefaultContainerSetting>
                                                </esbContainerSettings>
                                                <mfContainerSettings>
                                                        <DefaultContainerSetting>
                                                                <name>@MFESBContainer@</name>
                                                        </DefaultContainerSetting>
                                                </mfContainerSettings>
                                        </containerMap>
                                </configuration>
                        </plugin>
                </plugins>
        </build>