DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Spring Cloud Config With the Mule ESB
  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • Ensuring Reliable Microservice Deployment With Spring Boot Build Info Maven Plugin
  • New ORM Framework for Kotlin

Trending

  • Microservices With Apache Camel and Quarkus (Part 5)
  • Best Practices for Writing Clean Java Code
  • Podman Desktop Review
  • Essential Complexity Is the Developer's Unique Selling Point
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. WSO2 ESB Properties Tutorial

WSO2 ESB Properties Tutorial

Learn about the different types of properties in WSO2 ESB, what they do, and how and when to use them in this educational tutorial.

Chanaka Fernando user avatar by
Chanaka Fernando
CORE ·
Oct. 04, 17 · Tutorial
Like (4)
Save
Tweet
Share
13.42K Views

Join the DZone community and get the full member experience.

Join For Free

What Are Properties?

WSO2 ESB provides properties as a way to control different aspects of the messages flowing through the mediation engine. They will not change the content (payload) of the message, but they will be used to change the behavior of the message flowing through the ESB. The property mediator is used to access or modify the properties defined in the WSO2 ESB.

You can define a property mediator inside the ESB configuration language as below if you are setting a static value for the property.

<property name="TestProperty" value="Chanaka" scope="default" type="STRING">

If you are setting a dynamic value for the property, then you can use the following method.

<property name="TestProperty" expression="//m0:getQuote/m0:request/m0:symbol"

xmlns:m0="http://services.samples/xsd" scope="default" type="STRING">

In the above property declaration, you can find that we are defining a scope for the property. This scope definition will define the scope where this property can be visible inside the ESB.

1. default (Synapse)

Once you set a property under this scope, its value will be available throughout both the in- and out-sequences.

2. axis2

Once you set a property under this scope, its value will be available only throughout the sequence it's been set. If you set the Property mediator to the in-sequence, you cannot access it in the out-sequence.

3. axis2-client

This is similar to the Synapse scope. The difference is that you can access it in the following two ways inside a custom mediator:

public boolean mediate(org.apache.synapse.MessageContext mc) {
org.apache.axis2.context.MessageContext axis2MsgContext;
axis2MsgContext = ((Axis2MessageContext) mc).getAxis2MessageContext();
String propValue = (String) axis2MsgContext.getProperty("PropName");
System.out.println("SCOPE_AXIS2_CLIENT - 1 : " + propValue);

propValue = (String) axis2MsgContext.getOptions().getProperty("PropName");
System.out.println("SCOPE_AXIS2_CLIENT - 2: " + propValue);
return true;
}

4. transport

Once you set a property under this scope, it will be added to the transport header of the outgoing message from the ESB.

WSO2 has a huge set of mediators, but the property mediator is mostly used for writing any proxy service or API.

The property mediator is used to store any value or XML fragment temporarily during the lifecycle of a thread for any service or API.

We can compare the property mediator with Variables in any other traditional programming language, like C, C++, Java, .Net, etc.

There are a few properties that are used/maintained by the ESB itself, and on the other hand, a few properties can be defined by users (programmers). In other words, we can say that properties can be defined in the two categories below:

  • ESB-defined properties

  • User-defined properties

These properties can be stored/defined in different scopes, like

  • Transport
  • Synapse or Default
  • Axis2
  • Registry
  • System
  • Operation

Generally, these properties are read by the get-properties() function. This function can be invoked with the following variations:

  • get-property(String propertyName)
  • get-property(String scope, String propertyName)

The first function doesn’t require passing a scope parameter, which always reads properties from the default/synapse scope.

Performance Implication (Found in ESB 4.9.0 and Prior Versions)

It has been discovered that use of the  get-properties()function degrades performance drastically for any service. The get-properties()  function first does an ESB Registry look-u,p and then later on difference scopes- however, using scope identifiers limits its search to the relevant area only. This additional registry look up has been improved in the ESB 5.0.0 release. Hence, you will not get the same performance impact (which was there prior to ESB 5.0.0) even if you use get-property in ESB 5.0.0. But using $ctx is always the best approach.

Solution (Reading Through Scope)

Instead of using get-properties(), these properties can be referenced by the below prefixes separated by a colon:

  •  $ctx  – from Synapse or Default Scope
  •  $trp  – from Transport scope
  •  $axis2  – from Axis2 Scope
  •  $Header  – Anything from Header
  •  $body  – for accessing any element in SOAP Body (applicable for SOAP 1.1 and SOAP 1.2)

Let's assume that there is any property set with name “Test-Property.”

From Default Scope

<property name=”Read-Property-value” expression=”get-property(‘Test-Property’)”/>

<property name=”Read-Property-value” expression=”$ctx:Test-Property”/>


From Transport Scope

<property name=”Read-Property-value” expression=”get-property(‘transport’,’Test-Property’)”/>

<property name=”Read-Property-value” expression=”$trp:Test-Property”/>


From Axis2 Scope

<property name=”Read-Property-value” expression=”get-property(‘axis2′,’Test-Property’)”/>

<property name=”Read-Property-value” expression=”$axis2:Test-Property”/>


We should prefer to use the $ format to access these properties for better performance.

Note: This syntax cannot be used with a few ESB defined properties, mentioned below:

  • OperationName

  • MessageID

  • To

Please make sure you are using the correct way to access ESB-defined properties.

Enterprise service bus Property (programming)

Opinions expressed by DZone contributors are their own.

Related

  • Spring Cloud Config With the Mule ESB
  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • Ensuring Reliable Microservice Deployment With Spring Boot Build Info Maven Plugin
  • New ORM Framework for Kotlin

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: