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 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
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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Building a Robust Data Engineering Pipeline in the Streaming Media Industry: An Insider’s Perspective
  • Part 3 of My OCP Journey: Practical Tips and Examples
  • How To Use an Automatic Sequence Diagram Generator

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Building a Robust Data Engineering Pipeline in the Streaming Media Industry: An Insider’s Perspective
  • Part 3 of My OCP Journey: Practical Tips and Examples
  • How To Use an Automatic Sequence Diagram Generator
  1. DZone
  2. Data Engineering
  3. Databases
  4. Mule 4 — Log Response Time of Message Processors

Mule 4 — Log Response Time of Message Processors

Take a look at how to log and notify the message processors' response time using mule server notifications.

Praneeth Venishetty user avatar by
Praneeth Venishetty
·
Sep. 28, 20 · Tutorial
Like (2)
Save
Tweet
Share
2.69K Views

Join the DZone community and get the full member experience.

Join For Free

Every API to be developed on any technology will have both Functional and Non Functional Requirements to it. 

  • Functional Requirements are defined by the client who will use the API.
  • Non Functional Requirements are mandatory for any API to make the API available, be consistent, scalable, and perform efficiently.
    • Performance is one such metric that defines one of the non-functional requirements.

API Performance

Performance is a key factor to consider if an API is implemented and delivered efficiently and optimally. In any project life cycle, right before the production deployment or Go-Live Non Functional Requirements testing is a mandatory phase. Where performance testing is also carried out.

During the design of any API, we define SLAs with client systems on the response time of an API which when breached is considered as an NFR defect.

And so response time is the base metric that defines the performance of the API.

Whenever we talk about an API, we know that it comprises message processors, API invocations, etc. 

API invocations can be of different types like 

  • Invoking External or Third-Party APIs
  • Invoking Process API from Experience API, System API from Process API

The developer will not have any control over the response time of external/third-party APIs since they are being developed by external vendors and they abide by their own SLAs

But when it comes to processing APIs and system APIs, the response times have to be handled independently since they are internal and controlled by the internal developer.

So message processor optimizations are only the way to optimize the performance or response time of overall API.

This article explains the usage of Mule Server Notifications for logging and notifying response times of message processors present in Mule Flows using "Message Processor Notification" 

This feature helps a developer during NFR testing if there are any SLA breaches concerning performance metrics.

Use Case

As a developer, I want to optimize the response times of each message processor in a mule flow so that the overall response time of the API is largely optimized. 

Implementation Steps

  • Create a Mule Project

  • Create a Class — MuleComponentProcessListener  in src/main/java folder.

    • This class implements MessageProcessorNotificationListener Interface where we will be using the onNotification() method to log and notify.

      Create beans.xml file in src/main/resources folder 

  • Create a bean as below in beans.xml specifying the class created in step 2 for the type of notification we want to receive.

Java
 




x


 
1
<bean name="messageProcessorNotifications"
2
 class="message_processor_notifications.MuleComponentProcessListener" />



  • Add beans.xml reference to Spring Configuration as below

Java
 




x


 
1
<spring:config name="springConfig"
2
   doc:name="Spring Config" files="beans.xml" />



  • Mule Configuration

We have to specify notifications we want to receive using the <notification> element and have to register the listener class bean using <notification-listener> as below in Mule Configuration File.

Note: Listener Class is the Spring bean which we created in beans.xml at step 4

Java
 




xxxxxxxxxx
1
11
9


 
1
<notifications>
2

          
3
        <notification event="MESSAGE-PROCESSOR" />
4

          
5
        <notification-listener
6

          
7
            ref="messageProcessorNotifications" />
8

          
9
    </notifications>



Listener Class     

listener class

Testing

listener error handling

logger options

Please find the step by step guide, codebase, and video tutorial links provided below for implementing mule server notifications in mule flows.

Guide: https://docs.google.com/presentation/d/1luonPyU1QfOCNNotgv6jR2v3kSt4Xo_0z1JjwKzHhQ8/edit?usp=sharing

Codebase: https://github.com/praneethveni/mule-artifacts/tree/master/message_processor_notifications

Video Tutorial: https://youtu.be/Pb313qfPOJk

API

Opinions expressed by DZone contributors are their own.

Trending

  • Mastering Go-Templates in Ansible With Jinja2
  • Building a Robust Data Engineering Pipeline in the Streaming Media Industry: An Insider’s Perspective
  • Part 3 of My OCP Journey: Practical Tips and Examples
  • How To Use an Automatic Sequence Diagram Generator

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

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: