Adsense

May 12, 2021

Lightning Web Component


What is Lightning Web Component?
Lightning components can be built using two methodologies namely lightning aura component and Lightning web component. For end users both are same.
Lightning Web Components is a new framework for building Lightning components. For Lightning Web Components development you need to setup SalesforceDX and VsCode as Lightning web component are currently not available in Developer console.

In 2014, Salesforce launched the Lightning Component framework supported by the Aura programming framework. Since the web standards offered limited feasibility to build large-scale web applications at the time, Aura came with its component-driven model that allowed developers to build large-scale client applications on the web.

The web stack has seen an unprecedented level of innovation and standardization that transformed it from being a rudimentary page-rendering platform to a web development platform. This is the reason salesforce came with leveraging the offerings of web and let the heavy lifting to browser and code on top of it, which led them to created Lightning web component.

Introduction:
Lightning Web Components (LWC) is a stack of modern lightweight frameworks built on the latest web standards. It is a DOM (Document Object Model), element created through reusable code and is used to generate a dynamic interface without using JavaScript or building a Library. This feasibility makes it quick and seamless, saving the developers a ton of time and effort on the Web Stack. Let’s look at some of its remarkable features:
  1. Improved performance of the component as most of the code is recognized by the native web browser engine and web stack.
  2. Ability to compose applications using smaller chunks of code since the crucial elements that are required to create a component is part of the native web browser engine and web stack.
  3. Increase in the robustness of the applications built using LWCs as they are inclusive of the said modern web standards.
  4. Parallel interoperability and feasibility to use both Lightning Web Components and Aura components together in the applications with no visible differentiation to the end-users.

           
Web Stack Transformation:
Let's have a look on the web stack transformation which helped salesforce to coin new concept of building lightning components(LWC).
Web Stack Transformation
Web Stack Transformation


While developing prior to 2019, there use to be a layer between web stack and UI. The mid-layer languages basically comprise of javascript, which is now part of modern web standards.

With browser getting mature, it give more power to our web Stack to create a lightning UI component, It doesn’t require a mid-Layer to the browser which impacts our speed and performance. This one is the main reason developers are struggling within Aura.

Aura-based Lightning components are built using both HTML and JavaScript, but Web Component(LWC) is built directly on the Web stack.

Creating an LWC is fast as it no longer requires the user to download the JavaScript and wait for the engine to compile it before rendering the component.

Lightning Web Components supports the same browsers as Lightning Experience.

Note: Development of LWC component is not supported in Developer Console.

Read More »

January 17, 2021

How to exclude files from deployment - Mule4

Hello Friends,

In this article, I want to show to you how you can skip or exclude flow from initialize and start while deploying mule 4 applications in local or in cloud. Also, I will show you how you can exclude files from packaging jars.

Problem: 

In mulesoft development there are high chance of having large number of files for flows/ subflows and due to this it leads to:
  • Long build and deployment time.
  • Bulk packaging.

Above scenarios are more painful when we need a quick fix and testing of code in local or in cloud environment.


Let's check scenario below, as we are able to see in project below we have three files under src/main/mule package. Each file is having individual flows as highlighted in picture below:



mule4-flows



In mule4, we have "mule-artifact.json" file where we can declare files to be considered for initializing and starting of the flows under configs tag. By default, if we don't declare any file names, Mule runtime includes All files to check, initialize and starting of the flows.


mule-artifact-json.png


Below logs shows only "HelloWorldFlow" is initialized and started for deployment.

flow-logs




So, if we don't declare any file to include for execution, below logs shows mule runtime started and initialized all flows from all files.
flow-logs



Although above configuration helps you to exclude flows to initiate and start while deploying application in local or in cloud. It helps to reduce total deployment time of mule apps. But with above configuration you will not be able to exclude files or folders from packaging jar.


How to exclude files or folders from packaging jars?


To achieve this, we need to create "_muleExclude" file at the root level of mule application.




_muleExclude-mule4.png



You can declare file names to exclude from packaging jar as shown above.
Above picture also shows extracted jars is not having files included inside "_muleExclude" file.

Note: Please make sure above configurations should be used wisely as it may lead to application failure.

If you want to know more about minMuleVersion you can check my article runtime-patching-in-mule-munit


Happy Learning :)
Read More »

January 14, 2021

Filter complex array using dw2-Mule4

Hello friends,

In this article I will show you how we can filter results from complex Arrays. In this use-case we will use select and descendent operators from Mulesoft dataweave.

In this use-case we will try to find out the Book details which is at-least rented once from Library. We will see some variations to dataweave expressions in below section.



Input Payload:

[
  {
    "bookId": "20200114",
    "bookType": "Fiction",
    "title": {
      "en": "Candide"
    },
    "message": {
      "en": ""
    },
    "bookDetails": [
      {
        "label": {
          "en": "Candide"
        },
        "Library": {
          "city": "Pune",
          "rented": {
            "count": "1"
          }
        }
      }
    ]
  },
  {
    "bookId": "20200115",
    "bookType": "Fiction",
    "title": {
      "en": "The Alchemist"
    },
    "message": {
      "en": ""
    },
    "bookDetails": [
      {
        "label": {
          "en": "The Alchemist"
        },
        "Library": {
          "city": "Kolkata",
          "rented": {
            "count": "0"
          }
        }
      }
    ]
  }
]

DW Script:
%dw 2.0
output application/json
---
payload[?($.bookDetails.Library.rented.count[0] >= "1")] default []


Output:
[
  {
    "bookId": "20200114",
    "bookType": "Fiction",
    "title": {
      "en": "Candide"
    },
    "message": {
      "en": ""
    },
    "bookDetails": [
      {
        "label": {
          "en": "Candide"
        },
        "Library": {
          "city": "Pune",
          "rented": {
            "count": "1"
          }
        }
      }
    ]
  }
]


Now let us understand the dataweave script in some details:

filter-complex-array-dw-script
DW-Script

We can add multiple conditions inside red brackets based on our requirement.
For example if we want to add filter books based on Library location. We can use
expression like below:

%dw 2.0
output application/json
---
payload[?(($.bookDetails.Library.rented.count[0] >= "1") and ($.bookDetails.Library.city[0] == "Pune"))] default []
%dw 2.0
output application/json
---
payload[?(($.bookDetails.Library.rented.count[0] >= "1") and ($.bookDetails.Library.city contains "Pune"))] default []

Here, important thing to understand about [0] inside red-brackets. Actually we either need
to use [0], because as we have already said in diagram that it iterates and evaluates each
record and give output result or contains operator to evaluate the condition. Also, when
we are having any count check and compare like "> or <" contains operator will not work.


When we are using selectors for filtering data with one more variation in expression.
Let's see some more variation where we can use descendent operator to evaluate
the results.

%dw 2.0
output application/json
---
payload[?(($..count[0] >= "1") and ($..city[0] == "Pune"))] default []
%dw 2.0
output application/json
---
payload[?(($..count[0] >= "1") and ($..city contains "Pune"))] default []


Results will remain same with expression used with descendent and contains operator.

Happy Learning:)
Read More »

January 10, 2021

How to lookup CSV table using Dataweave2

 Hello Friends, 

In this article we will see how to lookup CSV file data without converting it to xml/json or any other message format.

Let's take one example where we need to lookup data from CSV file and retrieve/filter results from the dataset. Here, we will take one very common dataset with employee details information and then we will filter the data with some set of desired condition.


CSV table Input

Name Location Pincode
Niral Pune 910002
Nikku Pune 910005
Shruthi Bhopal 843001
Manpreet Chandigarh 890021
Little John Mumbai 200011
Harry Delhi 100011
Tom Goa 500110

DW Script:

%dw 2.0
output application/json
---
(payload filter ((item, index) -> item.Location == "Pune"))


Output:
[
  {
    "Name": "Niral",
    "Location": "Pune",
    "Pincode": "910002"
  },
  {
    "Name": "Nikku",
    "Location": "Pune",
    "Pincode": "910005"
  }
]


In above example we are filtering data based on location. Here, we have not converted csv data in json before using filter. You can also store the results in dataweave vars and use those results based on your use-cases. 

Please find below some variations having same output as results:
%dw 2.0
output application/json
---
payload filter ($.Location == "Pune")


You can have multiple conditions also. Below expression, we are retrieving data from csv file inside project. You can use readUrl to load csv data from classpath and then use filter  based on Location and Pincode.
 
%dw 2.0
output application/json
var fiterResult= readUrl("classpath://csvFiles/ProfileDetails.csv","application/csv") filter ($.Location == "Pune" and $.Pincode == "910005")
---
fiterResult

Output:
[
  {
    "Name": "Nikku",
    "Location": "Pune",
    "Pincode": "910005"
  }
]



Happy Learning :)

Read More »

January 05, 2021

Validation module indepth - Mule4

 Introduction:

Mulesoft has provided a bunch of validation components which is very useful for message field validation during developments. These validations can be general or based on specific requirements. Validators are used to verify that parts of the Mule message/events to meet some kind of criteria which we specify.

If a message doesn't meet the validation criteria, validation component generates Validation error. Here, we can customize the exception message that is displayed in logs/responses.

Let's see some of important and frequently used validation components

mule4-validation-module
mule4-validation-module

Is not null:

This components checks if the field value should be not null or else throws' error with "Name is Mandatory field"

<validation:is-not-null value="#[payload.name]" message="Name is Mandatory field"/>

Is email:

This components checks if the incoming email field is in valid format or not else throws validation error with message "Invalid Email format".

<validation:is-email email="#[payload.email]" message="Invalid Email format"/>

ALL vs ANY

To perform multiple validation at a time in mule flow. Mulesoft provides two scopes ALL and ANY which is used for these purpose.

ALL:- All validation should be passed from a set validation components defined in ALL scope.

<validation:all>
      <validation:is-not-null value="#[payload.name]" message="Name is Mandatory field"/>
      <validation:validate-size value="#[payload.name]" min="5" max="20" message="Name field size should be between 5 and 20"/>
</validation:all>

Here we are checking name field should not empty and name length should be minimum length 5 and max 20. It is similar to AND conditions like any programming language.

ANY:- Any of the validation components should be passed from a set of Validation components defined in ANY scope

<validation:any>
  <validation:is-not-null value="#[payload.name]" message="Name is Mandatory field"/>
  <validation:validate-size value="#[payload.name]" min="5" max="20" message="Name field size should be between 5 and 20"/>
<validation:any>

With Any scope we are ensuring any of the above condition should pass, it will pass the the validation. It is similar to OR conditions like any programming language.

Based on project requirement we can used these scopes with multiple validation components at a time.


Use of validation module Dataweave:

Now let us see how we can use these mule validation components can be used as Mule expression to make decisions without throwing any validation errors.

<choice>
   <when expression="#[ Validation::is-not-null(payload.name) and Validation::is-not-null(payload.name)]">
	<set-payload value='#[payload.name ++ " is a valid name."]'/>
   </when>
   <otherwise>
        <set-payload value='#[payload.name ++ " is NOT a valid name."]'/>
   </otherwise>
</choice>


Happy learning :)

Read More »

January 01, 2021

WSO2 Basic Overview

WSO2 Introduction:

WSO2 is an open-source technology provider which offers an enterprise platform for integrating application programming interfaces (APIs), applications, and web services locally and across the Internet.

WSO2 solutions give enterprises the flexibility to deploy applications and services on-premises, on private or public clouds, or in hybrid environments and easily migrate between them as needed.

WSO2 Platform:

WSO2 platform provides 3 main products to design and maintain application.

API Manger, Enterprise Integrator and Identity Server

WSO2-products
WSO2-products



API MANAGER

Api Manager helps to design and consume APIs. API Gateway helps to manage API requests and apply policies to them. API rate limiting feature helps to regulate traffic and secure against security attacks. API security provide Authentication and authorize features to API requests. 

API Manager provides Analytics feature to monitor application behavior and 

API management platform is available for on-premises, cloud, and hybrid architectures.




ENTERPRISE INTEGRATOR
Enterprise integrator provides hybrid integration platform. It enables API-centric integration using integration architecture styles such as microservices or centralized ESB.
 
WSO2 Enterprise Integrator is having 2 different architectural styles:
  • Micro Integrator: It is event-driven standard message based engine. It supports message routing, transformation and other type messaging use-cases. Micro integrator is used when you need centralized, API-driven integration architecture. Micro integrator can also be used where you need a decentralized cloud-native integration like Microservices and where you need low-code integration and application monitoring.


















  • Streaming Integrator: It is very useful for performing ETL (Extract, Transform, Load) and where streaming operations required. It provides real time analysis of streamed data with the help of SQL-like query languages. Streaming integrator is fully compatible with systems like Kafka and NATS to full utilize of stream data. It has native support to work with WSO2 Micro integrator to trigger complex integration flows.


Benefits of WSO2 ESB

  • Ensures loosely coupled solution with easy to manage plug-ins.
  • Suited for Scalable design.
  • It provides agile incremental solutions for development, early/often deployment, and seamless change management.
  • Configuration driven design, as opposed to code driven design.

IDENTITY SERVER

WSO2 Identity server is an open source API-driven tool which provides CIAM(Customer identity and access management) solutions effectively.
It is extensible, highly scalable platform which helps to manage identities at both cloud and enterprise environments. With CIAM solutions, it gives enhanced, seamless, and secure digital experiences.






Happy Learning :)
Read More »

December 30, 2020

.NET key concepts and introduction of .NET Core

What is .NET Core? Is this the future of .NET? Is this will obsolete the existing platform? Is this backward compatible? If all this are buzzing in your mind, please take a cup of coffee and go through the below topic, I promise you when you have your last sip of coffee you will have brief idea about this booming topic.

Basic of .NET

.NET is a free, open-source development platform for building many kinds of apps. .NET is open source, using MIT and Apache 2 licenses. A .NET app is developed for and runs in one or more implementations of .NET. .NET Framework, .NET 5 (and .NET Core), and Mono are the three most important implementations of .NET. Below are the key concepts of .NET.

 

What is .NET Standard?

There are various implementations of .NET. Each implementation allows .NET code to execute in different places—Linux, macOS, Windows, iOS, Android, and many more. .NET Standard is a formal specification of the APIs that are common across all these .NET implementations.

The relationship between .NET Standard and a .NET implementation is the same as between the HTML specification and a browser. The second is an implementation of the first.

Each .NET version has an associated version of the .NET Standard. .NET Standard is defined as a single NuGet package because all .NET implementations are required to support it. Tooling becomes easier because the tools have a consistent set of APIs to use for a given version. You can also build a single library project for multiple .NET implementations.


.NET Ecosystem

.NET includes the below components for each implementations:

.NET Ecosystem



.NET Implementations

There are four .NET implementations that Microsoft supports:

.NET Implementations


 Glimpse of .NET Implementations

.NET Implementations

What to choose when? (.NET Framework and .NET 5(including .NET Core))

Microsoft maintains both runtimes for building applications with .NET, and they share many of the same APIs. This shared API is what is called the .NET Standard.

.NET 5


Pick .NET 5

ü  If there is a new application to build, and have a choice between .NET Core and .NET Framework, .NET Core is the way to go.

ü  If the application need cross platform implementation(Windows, Linux, and macOS)

ü  Microservice architecture supported, so it allows the cross platform service developed under .NET framework, Ruby, Java etc communicate within another

ü  Containers are the VMs of today. .NET Framework can be used on Windows containers but .NET core is more modular, flexible and lightweight and after containerize because of it’s cross platform nature it can deploy in various Docker(ex:- Linux Docker containers)

ü  .NET CORE is one of the best performing one among web based frameworks in terms of performance and scalability 


Pick .NET Framework

ü  If existing application is .NET framework and there is no mind to change it

ü  The old technologies are using in the project which are not yet incorporated in .NET CORE(ASP.NET webforms , Visual Basic and F#)

ü  In cases where the libraries or NuGet packages use technologies that aren't available in .NET Standard or .NET 5 then it is required the .NET framework.


Happy Learning :)

Read More »

December 27, 2020

Pattern Matching in Dataweave Using Match Case

 Bonjour!

Just like any other programming language, In Mule4, dataweave provides match function to achieve the functionality of if-else statements. 

A match expression contains a list of case statements that can optionally have an else statement. Each case statement consists of a conditional selector expression that must evaluate to either true or false.

Let's consider a scenario where you need to update certain fields of incoming payload keeping the rest of the fields as it is, you can use a match and case

for example, the following is the input JSON object:

Input:

{
    "address": {
     "houseNumber" : null,
"street" : "IOC Road",
"pincode" : "111222",
"landmark" : "Statue of unity",
"city" : "Ahmedabad",
"state" : "Gujarat",
"country" : "India"
    }
}

Dataweave Transformation:

%dw 2.0
output application/json
var flag = if (payload.address.houseNumber == null) false else true
---
{
"updateAddressRequest":
payload.address mapObject (value,key,index) ->(
key as String match {
case "pincode" -> {(key): "000000"}
case "houseNumber" -> {(key): if(flag == false) "00" else ""}
else -> {(key):(value)}
}
)
}

Output:


{
"updateAddressRequest": {
"houseNumber": "00",
"street": "IOC Road",
"pincode": "000000",
"landmark": "Statue of unity",
"city": "Ahmedabad",
"state": "Gujarat",
"country": "India"
}
}

What we did here with the input JSON object is that we matched the keys using keyword match and then based on a condition updated the value of the key. We then used the else keyword in order to keep the rest of the fields the same as the input. 

In above example we are updating houseNumer and pincode field with case and other fields are remains same with else block.

This is also an example of how we can use the match case with mapObject

Pattern matching using Match Case can be done on Literal values, on expressions, on Data Types, and on Regular Expressions. 

Adios amigos!



Read More »

December 22, 2020

How to pass payload using Get method-Mule4

Hello Friends, 

I recently worked for one of API implementation where I needed to encrypt and send/receive one or more field in queryParms/headers while calling Get operation to external system.

As per API standard Get method should not pass payload as body while calling any Apis or 3rd party systems. Get method supports Uri Params, Query Params or Header Attributes.

In this article, I will show you the technique how you can pass encrypted payload using Http Get method. This is one of tricky interview question which normally asked in Mulesoft or Api Design related interviews.

As we know the when we encrypt any value it will not be a single string. Encrypted value may be of be multiple line as given below for PGP encryption for value 123456

-----BEGIN PGP MESSAGE-----
Version: BCPG v1.58

hIwDmCS94uDDx9kBA/9NIO0Kq9+yhXBLQveoykVjbECqXnGM8DargSsBxE2xBLQP
000W7mre5YpeSRJi4dvjVkAKPaxIFJhHlUNv38i5DkGD/z53SKtbKfYdfT+3oHT4
SVnIkcqWM+i+xawrKSk8Lz+j5GaJZ+wQrrxi8TP9RVW+wZlcbBNfxZVShDYp8dJX
AX9/x+1dFyO0EtHBipB0MLOqrb+sua028HGcg7E/sptn89JAgUcNEXOurVSfN6Ws
P/KxUMQY9+KKQQKavJ6LC92a6GJhVk4S+cnY1sxDLGtqKcGd+qCd
\u003dwGi2
-----END PGP MESSAGE-----



For both scenario(send/receive) we will be using (dw::core::Binaries) module from dataweave

toBase64(Binary): String


It takes Binary as input and returns result as base64 encoded String.

encoding
base64 Encoding




fromBase64(String): Binary


It takes base64 encoded String and returns original Binary data as a result.

decoded
base64 decoding



In this article we have seen how to convert encrypted payload to base64 encoded string and vice-versa. We can do the same conversion and pass with other payload type like JSON/XML etc..
These two dataweave functions are quite useful while dealing with payload with GET method.


Happy Learning :)
Read More »

December 19, 2020

Mulesoft Interview Questions With Answers - Part 2

Bonjour!

Let's take a look at some more Mulesoft basic interview-related questions!

Which component is used for schema validation and routing incoming Mule messages against RAML?

APIkit Router. 

Mule provides APIkit Router for Schema validation and routing the incoming Mule messages, serializing responses, validating payloads, Query parameters, URI parameters against RAML


Where are the HTTP, database configurations defined?

Global.xml

What is the purpose of a domain project?

The main purpose of a domain project is to have all the globally shared configurations for the projects. All the shared resources can be configured in a domain project. Mule applications can be associated only with one domain project. However, a domain project can be associated with multiple mule applications.


Does Cloudhub support Mule domain projects?

No, Mule domain projects neither supported in Cloudhub nor in Runtime Fabric. Domain projects are supported in on-premises environments.


Which connector is used for handling SOAP requests?

Web service Consumer.

How we can invoke REST or SOAP Services?

To invoke REST we can use HTTP and the Web service Consumer connector can be used to invoke SOAP services.


What is the use of Message Enricher?

In Mule 3, Message enricher is a component used to enrich the current message with additional information from a separate resource without disturbing the current payload.

Enricher is used in scenarios where the target system needs more information than the source system can provide. It calls an external system or doing some transformation to the current payload and saving it in a target variable.


Do we have Message Enricher in Mule 4? 

In Mule 4, We don't have a message enricher anymore. 
Now, every component is embedded with a target variable which solves the purpose. 
 

How do you override application properties?

You can configure your Mule application to automatically load properties from properties files based on different environments (Production, development, testing, QA) using property placeholders. 

1.  Create a properties file for each development environment in your Mule application.
2. Configure a property placeholder in your application to look for the environment at the time of launch.
3. Set environment variable one each for the different environment.

The property placeholder will then take up an environment variable value and based on that use the properties file.


How can we store sensitive data such as Client ID and Client Secret? 

Properties in Mule 4 can be encrypted to store sensitive data such as Client ID and Client Secret. We can encrypt a .yaml or .properties file using the secure properties module. For more details about the use of  secure properties: securing-configuration-properties-in-mule


Give some examples of popular Mulesoft connectors? 

HTTP, File, FTP, SFTP, Database, Salesforce, SAP, AWS, etc.


Can you create a custom connector? 

Yes. 

When an API specification is published to Anypoint Exchangeit automatically generates a connector for it. You can find out a list of Mulesoft connectors here.


Advantages of Mulesoft Anypoint connectors? 

  • It provides integration of Mulesoft application with different 3rd party systems like Facebook, Twitter, Salesforce, etc.
  • It is easier to maintain and no need to spend time on optimization and security.
  • It provides reusability which helps in speed-up development.


Is Mulesoft PaaS or SaaS? 

Mulesoft provides iPaaS (Integration Platform as a Service). It provides connectivity across on-premises and SaaS applications.


In Mule4 how you can generate custom errors.

By using the Raise Error component


In Mule 4, how errors are handled in a mule flow?

When an error is thrown in Mule flow while processing an event first step is it stops normal flow execution and it will not go to the next components. Then depending on the error type either error will be caught and handled inside the error handling block or thrown up to its parent flow.


Where we can add an error handler in the Mule 4 application?

An error handler can only be added to

– A flow

- A private flow

– A Try scope

– An global error handler (outside of any flows) is then referenced to any of the error handling strategies.

Note: Error handler can not be added to subflows.


What is the Mule default error handler?

When there is no error handler defined for any flow or by using try scope, the Mule default error handler will be used. This default handler should be configured globally.


What if the default error handler not configured in the Mule application?

If the default error handler is not configured then Mule runtime will provide its own default behavior

– First, it stops the execution of the flow and logs information about the error.

– Implicitly and globally handles all errors thrown in Mule applications.

– It automatically rethrows the error.

– Most important we cannot configure it.


What are error scopes in mule4 to handle errors?

– On Error Continue scope

– On Error Propagate scope

 

Can you please explain the difference between these two error scopes in Mule4?


What is the use of Try scope in Mule4?

Try Scope is very useful when you need to group a set of events/ components and want to handle errors based on your specific requirements. It acts as a private flow inside the parent flow. For Unhandled errors, it propagates to its parent flow.



Read More »