This documentation is for WSO2 Enterprise Service Bus version 4.9.0 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

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.



Configuration

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

<endpoint  name="ep1">
            <default>
               <suspendOnFailure>
                     <errorCodes>10001,10002</errorCodes>
                     <progressionFactor>1.0</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                     <retriesBeforeSuspension>5</retriesBeforeSuspension>
                     <retryDelay>0</retryDelay>
                </markForSuspension>
            </default>
</endpoint>
<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:

<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>

Note

$ 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.

<endpoint name="ep1" template="ep_template">
           <parameter name="codes" value="10001,10002" />
	   <parameter name="factor" value="1.0" />
	   <parameter name="retries" value="5" />
</endpoint>
<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

<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:

<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>

Note

$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

<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.

Note

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.

  • No labels