Sunday, August 31, 2014

[WSO2 ESB] How to Read Local Entries and Registry Entries

This post is rather a quick note to my self. In WSO2 ESB we can have external reference to a file using either a local entry or a registry entry. 

Local-entry :

An entry stored in the local registry. The local registry acts as a memory registry where you can store text strings, XML strings, and URLs. These entries can be retrieved from a mediator.

Registry-entry :
WSO2 ESB makes use of a registry to store various configurations and artifacts such as sequences and endpoints. A registry is a content store and a metadata repository. Various SOA artifacts such as services, WSDLs, and configuration files can be stored in a registry and referred to by a key, which is a path similar to a UNIX file path.

1. This is how we can read some value stores in a local-entry. Let's say i have a value stored in local-entry file 'testEntry'.

<localEntry xmlns="http://ws.apache.org/ns/synapse" key="testEntry">12345</localEntry>

 This is how we can read this value into a mediator.

<property name="testProp" expression="get-property('testEntry')" scope="default" type="STRING"/>

2. If this 'testEntry' file is stored in the registry we have to use 'registry' scope with get-property() XPath extension function and read entry as below.

<property name="testProp" expression="get-property('registry', 'conf://custom/testEntry')" scope="default" type="STRING"/>

2 comments:

  1. Can multiple entries be placed in the same file? I'm trying to do this but only the first entry is being uploaded to the registry.

    ReplyDelete
  2. Hi Ishara,
    Is there any way to read a local entry from an endpoint?
    For example, assume I've defined different Endpoints according to different web services. For example, assume I have a endpoint whose the uri is http://10.223.162.15/api/products, I want to store the ip address "10.223.162.15" in a local entry, then in the endpoint definition I can reference to it by the endpoint name/key.

    Thanks you so much

    ReplyDelete