This documentation is for WSO2 Enterprise Service Bus version 4.8.0 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Endpoint template is a generalized form of endpoint configuration used in ESB. Unlike sequence templates , endpoint templates are always parametrized using $ prefixed values (not XPath expressions).

Template endpoint is the artifact that makes a template of endpoint type into a concrete endpoint. In other words, an endpoint template would be useless without a template endpoint referring to it. This is semantically similar to the relationship between a sequence template and the Call Template Mediator.


Table of Contents
maxLevel3
minLevel3
styleborder:1
locationtop
typeflat
separatorpipe


Configuration

For example, let's say we have two default endpoints with following hypothetical configurations:

Code Block
<endpoint  name="ep1">
            <default>
               <suspendOnFailure>
                     <errorCodes>10001,10002</errorCodes>
                     <progressionFactor>1.0</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                     <retriesBeforeSuspension>5</retriesBeforeSuspension>
                     <retryDelay>0</retryDelay>
                </markForSuspension>
            </default>
</endpoint>
Code Block
<endpoint  name="ep2">
            <default>
               <suspendOnFailure>
                     <errorCodes>10001,10003</errorCodes>
                     <progressionFactor>2.0</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                     <retriesBeforeSuspension>3</retriesBeforeSuspension>
                     <retryDelay>0</retryDelay>
                </markForSuspension>
            </default>
</endpoint>

We can see that these two endpoints have different set of error codes and different progression factors for suspension. Furthermore, the number of retries is different between them. By defining a endpoint template, these two endpoints can be converged to a generalized form. This is illustrated in the following:

Code Block
<template name="ep_template">
     <parameter name="codes"/>
     <parameter name="factor"/>
     <parameter name="retries"/>
     <endpoint name="$name">
            <default>
               <suspendOnFailure>
                     <errorCodes>$codes</errorCodes>
                     <progressionFactor>$factor</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                     <retriesBeforeSuspension>$retries</retriesBeforeSuspension>
                     <retryDelay>0</retryDelay>
                </markForSuspension>
            </default>
     </endpoint>
</template>
Info
titleNote

$ is used to parametrize configuration and $name is an implicit/default parameter.

Since we have a template defined, we can use template endpoints to create two concrete endpoint instances with different parameter values for this scenario. This is shown below.

Code Block
<endpoint name="ep1" template="ep_template">
           <parameter name="codes" value="10001,10002" />
	   <parameter name="factor" value="1.0" />
	   <parameter name="retries" value="5" />
</endpoint>
Code Block
<endpoint name="ep2" template="ep_template">
           <parameter name="codes" value="10001,10003" />
	   <parameter name="factor" value="2.0" />
	   <parameter name="retries" value="3" />
</endpoint>

As with the Call Template Mediator, the above template endpoint will stereotype endpoints with customized configuration parameters. This makes it very easy to understand and maintain certain ESB configurations and improves re-usability in a certain way.

Syntax

Code Block
<template name="string">
   <!-- parameters this endpoint template will be supporting -->
   (
   <parameter name="string"/>
   ) *
   <!--this is the in-line endpoint of the template    -->
   <endpoint [name="string"] >
           address-endpoint | default-endpoint | wsdl-endpoint | load-balanced-
endpoint | fail-over-endpoint
     </endpoint>
</template>

Similar to sequence templates, endpoint templates are defined as top level element (with the name specified by the name attribute) of ESB configuration. Parameters (for example, <parameter>) are the inputs supported by this endpoint template. These endpoint template parameters can be referred by $ prefixed parameter name. For example, parameter named foo can be referred by $foo. Most of the parameters of the endpoint definition can be parametrized with $ prefixed values. This is shown in the following extract:

Code Block
<template name="sample_ep_template">
            <parameter name="foo"/>
            <parameter name="bar"/>
            <default>
               <suspendOnFailure>
                     <errorCodes>$foo</errorCodes>
                     <progressionFactor>$bar</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                     <retriesBeforeSuspension>0</retriesBeforeSuspension>
                     <retryDelay>0</retryDelay>
                </markForSuspension>
            </default>
     </endpoint>
</template>
Info
titleNote

$name and $uri are default parameters that a template can use anywhere within the endpoint template (usually used as parameters for endpoint name and address attributes).

Template Endpoint Sample

Code Block
<endpoint [name="string"] [key="string"] template="string">
 <!-- parameter values will be passed on to a endpoint template -->
(
<parameter name="string" value="string" />
) *
</endpoint>

Template endpoint defines parameter values that can parametrize endpoint. The template attribute points to a target endpoint template.

Info
titleNote

Parameter names has to be exact match to the names specified in target endpoint template.

WSO2 ESB allows add, delete, and edit endpoint templates. 

For more information about templates, see Working with Templates.

Excerpt
hiddentrue

Description of endpoint template.