In my previous blog I explained new Mule 4 feature and enhancement of Mule runtime. To support these feature Mulesoft released new editor with new look and feel. If you are coming from Mule 3 and its Anypoint studio, you will not find much difference but there is lot of makeover of editor and some cool feature in Anypoint studio 7.0. With new Anypoint studio, it accelerates developer productivity with a single graphical environment for integration with SaaS and on-premises systems, API implementation, and testing. It Deploys your applications on-premises or in the cloud with Mule runtime engine. Anypoint Studio is MuleSoft’s Eclipse-based integration development environment for designing and testing Mule applications.
Now let’s move on new Anypoint studio features and configuration.
1. Installation & Configuration – Download
and installation of Anypoint studio is available based on operating system.
Download your Anypoint studio based on your operating system. Make sure JDK 1.8
in install and configure in your system before installation of Anypoint studio.
This version of Studio is not compatible with Java 9 or Java 10. MuleSoft
recommends a minimum of 4GB of free RAM, 2GHz CPU and 10GB free hard drive
space available on a developer workstation. To install Anypoint studio you need
to extract your download zip file and
set your workspace area in your system. If you are still getting java error
during your Anypoint start. Please open AnypointStudio.ini file and add this line in this file
-vm C:\software\java\bin
2. Maven – This version of Anypoint studio comes with Maven installation default. You no need to install maven separately like previous version. Studio comes with Maven 3.3.9 bundled, but you can externally use the versions: 3.3.3 or your own 3.3.9.
3. Mule palette — If you are coming from previous version of Anypoint studio you will find extreme make over for Mule palette in newer version of Anypoint studio. It has added couple of section and related action in this Mule palette to speed up the development process. It created two level of palette to improve access times, discoverability and categorization. You can search connector and add modules from Mule palette. You can also search your project/modules in exchange from Mule palette. There is Favorites section you can add most used connector and action. Here is couple of sections of Mule palette
Category List
Manage you modules
Operation inside the category
Search Modules from Exchange
Add Modules to your current project
Favorites
Add to favorites
4. Editor/Canvas—Studio editors helpyou design and edit the definitions of your applications, APIs, properties, and configuration files. In canvas you can see all visual representation of your flows. These flows are collapsible Flows. In new Anypoint editor you can now preview the content of the collapsed flow by simply hovering over the region for a second. New version editor it added new set of graphic icons for better usability. In new Anypoint studio new feature added to navigate from visual view to XML view by simple right clicking on any component and select “Go to XML”
5. Managing Anypoint platform credential—Through
Anypoint studio you can manage and configure Anypoint Platform credentials. To
enable this feature you have to browse in Anypoint studio top navigation
Now here you can add multiple user Anypoint platform credential. Once you add here now when creating a new Mule project (File > New > Mule Project), if you select an API implementation from Design Center, the toolbar displays at the top of the selection dialog.
Similarly, if you select Search in Exchange from the Mule Palette, the toolbar displays in a slightly different form.
6. Dataweave everywhere— As Mule 4 supporting Dataweave is default language. Now you can see new Anypoint editor enable Dataweave for all component. You can now toggle between “literal” and “Expression” modes using the new expression button. When clicking the “Expression” mode, you can use auto-suggestions for Dataweave 2.0.
Additionally, using the expression mode, you can click the New Map button next to Fields to use the visual mapper to build expressions for individual fields.
Conclusion—New Anypoint studio accelerates developer productivity with a single graphical
environment for integration with SaaS and on-premises systems, API
implementation, and testing. Studio enables you to deploy your applications on-premises or
in the cloud with Mule runtime engine.
Much awaited Mulesoft 4 was officially announced in Mulesoft
Connect 2018 in San Jose. When Mulesoft was born, it was really to create
software that helps to interact systems or source of information quickly within
or outside company. So the speed is an incredibly important thing over the
years to develop and interact within systems. Need of speed for application and
development hasn’t change drastically over the years but needs and requirement
of customer’s application have changed. The integration landscape has also
magnified. There are hundreds of new systems and sources of information to
connect to, with more and more integration requirements. This integration
landscape gets very messy and very quickly.
Mule 4 provides
a simplified language, simplified runtime engine and ultimately reduces
management complexity. It helps
customers, developers to deliver application faster. Mule4 is really radically
simplified development. It is providing new tool to simplify your development,
deployment and management of your integration/API. It is also providing a
platform to reuse Mule component without affecting existing application for
faster development. Mule 4 is evolution of Mule3. You will not seem lost in
Mule 4, if you are coming from Mule3. But Mule 4 implements fewer concepts and
steps to simplify whole development/integration process. Mule 4 has now java
skill is optional. In this release Mulesoft is improving tool and making error
reporting more robust and platform independent.
Now let’s go one by one with all these new Mule4 features.
1. Simplified
Event Processing and Messaging — Mule event is
immutable, so every change to an instance of a Mule event results in the
creation of a new instance.It contains the core
information processed by the runtime. It travels through components inside your
Mule app following the configured application logic. A Mule event is generated when a trigger (such as an
HTTP request or a change to a database or file) reaches the Event source of a
flow. This trigger could be an external event triggered by a resource that
might be external to the Mule app.
2. New
Event and Message structure — Mule 4 includes a
simplified Mule message model in which each Mule event has a message and
variables associated with it. A Mule message is
composed of a payload and its attributes (metadata, such as file size).
Variables hold arbitrary user information such as operation results, auxiliary
values, and so on.
Mules 4 do not have Inbound, Outbound and Attachment
properties like Mule 3. In mule 4 all information
are saved in variables and attributes. Attributes in Mule 4 replace inbound properties. Attributes
can be easily accessed through expressions.
These
are advantages to use Attributes in
Mule 4.
They are strongly typed, so you can easily see
what data is available.
They can easily be stored in variables that you
can access throughout your flow
Example :
#[attributes.uriParams.jobnumber]
Outbound properties— Mule 4 has no concept for outbound properties like in Mule 3. So you can set status code response or header information in Mule 4 through Dataweave expression without introducing any side effects in the main flow.
Session Properties–In Mule 4 Session properties are no longer exist. Data store in variables are passes along with different flow.
3. Seamless data access & streaming – Mule 4 has fewer concepts and steps. Now every steps and task of java language knowledge is optional.Mule 4 is not only leveraging DataWeave as a transformation language, but expression language as well. For example in Mule 3 XML/CSV data need to be converted into java object to parse or reroute them. Mule 4 gives the ability to parse or reroute through Dataweave expression without converting into java. These steps simplify your implementation without using java.
4. Dataweave 2.0 — Mule 4 introduces DataWeave as the default
expression language replacing Mule Expression Language (MEL) with a scripting
and transformation engine. It is combined with the built-in streaming
capabilities; this change simplifies many common tasks. Mule 4
simplifies data iteration. DataWeave knows how to iterate a json array. You
don’t even need to specify it is json. No need to use <json:json-to-object-transformer /> to convert data into java object.
Here are few points about Dataweave 2.0
Simpler syntax to learn
Human readable descriptions of all data types
Applies complex routing/filter rules.
Easy access to payload data without the need for
transformation.
Performs any kind of data transformation,
normalization, grouping, joins, pivoting and filtering.
5. Repeatable
Streaming – Mule 4 introduces
repeatable streams as its default framework for handling streams. To understand
the changes introduced in Mule 4, it is necessary to understand how Mule3 data
streams are consumed
In above three different Mule 3 flows, once stream data is
consumed by one node it is empty stream for 2nd node. So in the above
first example, in order to log the stream payload , the logger has to consume
the entire stream of data from HTTP connector. This means that the full content
will be loaded into memory. So if the content is too big and you’re loading
into memory, there is a good chance the application might run out of memory.
So Mule 4 repeatable streams enable you to
Read a stream more than once
Have concurrent access to the stream.
Random Access
Streams of bytes or streams of objects
As a component consumes the stream, Mule saves its content
into a temporary buffer. The runtime then feeds the component from the
temporary buffer, ensuring that each component receives the full stream,
regardless of how much of the stream was already consumed by any prior
component
Here are few points, how repeatable streams works in Mule 4
Payload
is read into memory as it is consumed
If
payload stream buffer size is > 512K (default) then it will be persisted to
disk.
Payload
stream buffer size can be increased or decreased by configuration to optimize
performance
Any
stream can be read at any random position, by any random thread concurrently
6. Error Handling — In Mule 4 error handling has been changed
significantly. Now In mule 4 you can discover errors at design time with visual
interface. You no need to deal with java exception directly and it is easy to
discover error while you are building flow. Every flow listed all possible
exception which potential arises during execution.
Now errors that occur
in Mule fall into two categories
Messaging errors
System errors
Messaging errors — Mule throws a messaging error (a Mule error) whenever a problem occurs within a flow. To handle Mule
errors, you can set up On Error components inside the scope-like Error Handler
component. By default, any unhandled errors are logged and propagated.
System errors — Mule throws a system error when an exception occurs
at the system level . If no Mule Event is involved, the errors are handled by a
system error handler.
Try catch Scope — Mule 4 introduces a new try scope that you can use within a flow to do error handling of just inner components/connectors. This try scope also supports transactions and in this way it is replacing Old Mule 3 transaction scope.
7. Class Loader Isolation — Class loader separates application completely from
Mule runtime and connector runtime. So, library file changes (jar version) do
not affect your application. This also
gives flexibility to your application to run any Spring version without worry
about Mulesoft spring version. Connectors are distributed outside the runtime
as well, making it possible to get connector enhancements and fixes without
having to upgrade the runtime or vice versa
8. Runtime Engine — Mule 4 engine is new reactive and non-blocking engine. In Mule 4 non-blocking flow always on, so no processing strategy in flow. One best feature of Mule 4 engine is, It is self-tuning runtime engine. So what does this mean? If Mule 4 engine is processing your applications on 3 different thread pools, So runtime knows which application should be executed by each thread pool. So operation put in corresponding thread pool based on high intensive CPU processing or light intensive CPU processing or I/O operation. Then 3 pools are dynamic resizing automatically to execute application through self-tuning.
So now self-tuning creates custom thread pools based on specific tasks. Mule 4 engine makes it possible to achieve optimal performance without having to do manual tuning steps.
Conclusion
Overall Mule 4 is
trying to make application development easy, fast and robust. There are more features
included in Mule 4 which I will try to cover in my next blog. I will also try
to cover more in depth info in above topic of Mule 4. Please keep tuning for my
next blog.
Summer 2017 Salesforce released new event-driven architect “Platform Events” feature. Salesforce is known for its custom metadata platform, and now it is delivering a custom messaging platform, so Salesforce customers can build and publish their own events. Platform Events enables customer to increase business productivity and efficiency through integration via event. This feature reduces point-to-point integration and expands the existing capability with more integration options like Outbound Messaging, Apex Callouts, and the Streaming API. With platform events, there are two parties to the communication: a sender and a receiver. They are two of the components of an event-driven architecture.
Before going any further, let’s define some of terminology of platform event.
Event — A change in state that is meaningful in a business process. For example, if opportunities are created or updated in salesforce, this action will generate event within salesforce.
Event message – An event message is payload of event. For example, events are generated after creating or updating opportunities. So, this event has all updated data or updated delta of data which comes as payload.
Event producer – Publishing event with event message is event producer. For example, publish opportunities payload after generating event for other system.
Event channel — A stream of events on which an event producer sends event messages and event consumers read those messages.
Event consumer — A subscriber/Event consumer is an event channel that receives messages from the Event Bus. For example, Application which is subscribing event channel to process further is event consumer.
Event-based software architecture
Set Up Platform Events in Salesforce
On the Salesforce page, click the Setup icon in the top-right navigation menu and select Setup.
Enter Platform Events into the Quick Find box and then select Data > Platform Events.
Click New Platform Event.
In the New Platform Event form, please fill all form
Field Label: EnterpriseTestSync
Plural Label: EnterpriseTestSyncs
Object Name: EnterpriseTestSync
Click Save
It will be redirected to the EnterpriseTestSync Platform Event page. By default, it creates some standard fields.
Now you need to create Custom Platform Event fields that correspond to your EnterpriseTestSync. In the Custom Fields & Relationships section, click New to create a field for EnterpriseTestSync.
Make sure that the Enterprise Test Sync API Name is EnterpriseTestSync__e and that Custom Fields & Relationships looks like this.
If you have any trigger for platform event you can create in trigger section.
Click Save.
Save action will create platform event in salesforce. In next section create Mulesoft integration flow
Integration Mulesoft and Plateform Event
To Integrate with Salesforce Platform Events, please download Mulesoft Salesforce connector v8.4.0 or beyond from Anypoint Exchange.
In my example, I am creating application which syncs salesforce opportunity between two salesforce instances. So, any create or update opportunity will create platform event in salesforce instance. This platform event is subscribed by Mulesoft Salesforce platform event connector in first salesforce instance. Mulesoft receives platform event and platform message from first salesforce instance. Mulesoft transforms this platform message into another format of message and publishes into other salesforce platform event. Platform event can be tracked by replay id. Replay id is unique field when Salesforce generates any platform event. Platform event message persist only 24 hrs in platform Event Bus. We can replay this message within 24hrs.
Here are the steps for Mulesoft integration with Salesforce platform event and flow to communicate between two Salesforce platform event.
Please configure Salesforce Basic Authentication from global element in Anypoint studio.
Configure Salesforce connector for platform event which listen Salesforce platform event from event channel.
Select operation as “Replay streaming channel”
Streaming Channel: Add “/event/EnterpriseTestSync__e”. “EnterpriseTestSync__e” is API name from Salesforce platform event. This API listen event with /event/
Replay option: There are 3 options
ALL – This option replays all message from event channel
FROM_REPLAY_ID – This option replays only specific event message replay Id
ONLY_NEW – This option replay only new event messages from channel.
Replay Id: Replay option ALL we pass -1 value. For FROM_REPLAY_ID option we pass specific event message replay Id and for ONLY_NEW we pass -1
Check box “Resume from the Last Replay Id” resume from last replay Id and ignore rest.
Once it is configured, it is ready to accept event message from platform event Channel. Add transformation logic to publish platform event into other Salesforce instances.
Configure Salesforce platform event for publish event message into
Operation: Publish platform event message
Platform Event Name: Opportunity_Event__e
Platform Event Message: Default
Once you configure these ends point application is ready to listen Event from first instance of Salesforce Platform event and publish platform event into other instance of Salesforce.
IOT (Internet Of Things) is transforming whole business and bringing new revolution in all kinds of business. These IOT devices generating terabytes of data. To handle unprecedented volume, variety and velocity of data, IOT needs new kind of infrastructure to support whole IOT eco system. FOG computing is a part of IOT eco system to support large volume of data with quick response. I explained in my previous blog, how FOG computing is now becoming major role in IOT devices. FOG is intermediate platform to collaborate between Cloud computing and Edge computing(IOT) to transfer data. Fog can hold small number of data and less computing power. Large data is stored in cloud and heavy computing is done in Cloud.
API (Application Programming Interface) have major role to transfer data from edge device (IOT) to Fog node and from fog node to Cloud (Internet). API is helping to collaborate between edge device to Fog node and Fog node to Cloud. API is playing major role to maintain volume, variety and velocity of data in IOT infrastructure.
API works on HTTP/HTTPS protocol. APIs are light weight and simple. Enabling APIs take very small amount of resource. So, API can enable in small system and consume without losing too much resources. This API property helps to transfer data from Edge device(IOT) to Fog node and from Fog node to Cloud. API is not part of mechanical role. API is responsible for the optimization of data transfer. Proper enabling of APIs between these nodes increase the efficiency and computational power to all IOT devices. Fog node is intermediate node between IOT device and cloud. So, Fog node will be responsible to receive data from edge(IOT) device and transfer these data to Cloud. Communication between Edge(IOT) device to Fog node is very frequent. Data provided by API is responsible for all intermediate and quick computation on FOG node.
Cloud is still big stake holder for holding all data and large computation from IOT device. API is providing data to cloud from FOG node in certain interval for heavy computation. As Edge(IOT) system getting more complex Fog computation responsibility will increase and API will come on picture to provide more data to Fog and from fog node to cloud.
These are few benefits by enabling APIs for IOT devices and Fog Nodes
API provides flexibility to connect any IOT device to FOG node and FOG node to cloud network.
API provides seamless connectivity between these systems.
API brings whole IOT system in one seamless environment So, it is very easy to debug these systems.
API is very easy to develop and deploy so it’s easy to maintain these systems.
Provisioning of IOT device has also become very easy by enabling API.
According to Gartner study, Security of IOT is one of big concern. API provides whole one seamless system and network to mitigate this risk.
IOT, Connect car, Automated car getting lot of traction in current word. All big companies want to be part of this process. All kind of sensors are installed in these vehicles. These sensors generate Terabytes of data and computing these data to run vehicle smoothly. Connected car or IOT based devices are completely based on computing power and quick response.
Sending data and computing these data in cloud could be catastrophic. Any network latency and processing delay might end with bad result. For example, your automated car is traversing through busy street. Suddenly a person comes in front of automated car. In this scenario, any network latency, slowness of computation and analysis effects the decision and subsequent action (Apply brake on car).
In IOT based device, any computing near to IOT device can reduce this risk. So how can we make this happen, if your all computing power are in cloud and data is in cloud.
FOG Computing–In context of IOT, if intelligence pushes d down to the local area network (LAN) and compute these data in IOT gateway or FOG node will reduce network latency risk. Fogging or FogNetwork is decentralized computing and stores data in most logical and efficient place between IOT device and the cloud.
In FOG computing, data transported from IOT to Cloud need many steps.
Signals from IOT is transported through wire to I/O point of device programmable automation controller(PLC). PLC execute control system program to automate system.
Control system program sends data to protocol gateway, which convert this data into a protocol, understand internet systems such as MQTT or HTTP.
At the end, data is send to fog node or IOT gateway on the LAN, which collects the data and preform analysis and computing on data. This even stores the data to transfer further to cloud network for later processing and intelligence.
Edge Computing — Edge computing refers to any computing infrastructure near to source of data (i.e. IOT device). So, Making IOT device smart and intelligent enough to take decision near to data gateway. The role of edge computing is to process data, store data in local device and transfer data to fog or cloud network. Above all processes are automated through PAC (Programmable automation controller) by executing board controlled system program. In edge computing, intelligence literally push to edge of network where our IOT device and outside network first connect to each other.
When you start to build API there is always in your mind how can I make sure my all APIs are interlinked. How can a developer access these API without doing too much reengineering of your APIs? How all API URL can easily and well document through current API?
HATEOAS, an abbreviation for Hypermedia as the Engine of Application State, is a constraint of the REST application architecture. API Hypermedia provides a placeholder in existing API framework, so that you can define and document all of methods related with existing API. A truly RESTful API is with hypertext. By using hypermedia in responses we can offer links between existing endpoint and next possible API endpoints with documentation and corresponding actions. Defining hypermedia within your API leads to standardize your API call and reduce duplicate effort.
There are two key things that make hypermedia APIs useful within APIs:
shared other APIs information so that developers can communicate with the API
Documenting and guiding developers so that they can take action along the way
You can define Hypermedia several ways in APIs. Here are few famous Hypermedias available.
1. Hypertext Application Language (HAL) -HAL is an open specification describing a generic structure for RESTful resources. HAL provides its linking capability with a convention which says that a resource object has a reserved property called “_links”. HAL supports JSON and XML.
2. Collection+JSON– Collection+JSON is a JSON-based read/write hypermedia-type designed to support management and querying of simple collections. A typical Collection+JSON contain a set of links, list of items, a queries collection, and a template object.
3. JSON-LD — JSON-LD (JavaScript Object Notation for Linked Data ) is a lightweight Linked Data format based on JSON. JSON-LD is designed around the concept of a “context” to provide additional mappings from JSON to an Resource Description Framework(RDF) model. This linking is supported by JSON format.
4. Siren— Siren is a hypermedia specification for representing entities, offering structures to communicate information about entities. An Entity is a URI-addressable resource that has properties and actions associated with it. It may contain sub-entities and navigational links. Siren supports JSON and XML format.
5. JSON API — JSON API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests. Jason API ensures separation between client and server and also reducing the number of call without impacting discoverability. This is Json based and one of popular hypermedia for API.
These are few famous API hypermedia, developer are using to link their APIs and document. Along with all these hypermedia there are some more less popular hypermedia like Uber, Mason, Cj, Yahapi, Paypal,OData and CPHL.
There are few draw back about using hypermedia within API.
More data transport through network for hypermedia.
It makes complex to process and understand these links within APIs.
API Hypermedia is still not yet standardize. Most of these API hypermedias are still evolving and coming with new standard. This is one of the most active communities and developers are coming forward with their new API hypermedia concept.
Twilio is a cloud based communication company that enables users to use standard web languages to build voice, VoIP, and SMS apps via a web API. Twilio provides a simple hosted API and markup language for businesses to quickly build scalable, reliable and advanced voice and SMS communications applications. Twilio based telephony infrastructure enable web programmer to integrate real time phone call, SMS or VOIP to their application.
Mulesoft provides cloud connector to integrate Twilio Api within Mulesoft. Mulesoft Cloud connector provides a simple and easy way to integrate with these Twilio APIs, and then use them as services within Mulesoft. Mulesoft-Twilio connector provides a platform for developer to develop and integrate their application easily and quickly with Twilio.
Before start integration of Mulesoft with Twilio, create your Twilio account and get “ACCOUNT SID” and “AUTH TOKEN”.
Now download and install Twilio connector into Anypoint studio.
Anypoint Studio –>Help –>Install New Software
Configure pom.xml to pull Twilio jar dependency in maven based project.
Add plugin in plugin section and dependency in pom.xml file. This section will also add into pom.xml file when Twilio connector drag into AnypointStudio canvas and use it into flow.
In above code TwilioSID and TwilioAuthToken are coming from Twilio account.
Mulesoft Twilio connector provides a number of methods to integrate with your application. Below image show some of methods expose by Mulesoft-Twilio connector.
I am using “send SMS message” method form Mulesoft-Twilio connector for my example.
Now you can integrate Twilio to send SMS with your application. Here is example code.
<logger message="#[payload.recipientPhoneNumber]" level="INFO" doc:name="Logger"/>
<twilio:send-sms-message config-ref="Twilio" accountSid="${TwilioSID}" body="Hello World Sending SMS from Twilio" from="+15555555555" to="#[payload.recipientPhoneNumber]" doc:name="Twilio"/>
Twilio API does not support bulk SMS for recipient. So, to initiate messages to a list of recipients, you must make a request for each number to which you would like to send a message. The best way to do this is to build an array of the recipients and iterate through each phone number.
Initially when REST was introduced there was always challenge to validate your request against prerequisite requirement. This was available in SOAP web services as XSD schema validation but it was not available in REST webservice. Architect and developer had to face the challeng to implement some kind of schema to validate their request.
YAML based RAML (Restful API modeling Language) was introduced in 2013. RAML gives flexibility to define schema to validation request/response. This breakthrough helps Architect and developer to define schema for REST API to validate request/response.
RAML schema validation can be defined in two formats.
1) XSD Based
2) Json Based.
Schema validation can be defined in two ways inside RAML
1) Inline schema definition
2) XSD or json schema definition file.
Schema definition can be defined in schema tag within RAML file. “!Include” tag uses to include schema file for file based schema definition within RAML.
Json based schema definition
/car: post:description:Getting car info from Car Applicationbody: application/json:schema: !includeschemas/cars-schema-request.json
In my previous blog I explained configuration and setup for Mulesoft connector Devkit. In this blog I am going to explain how to write and deploy your connector. As I mentioned in my previous blog Devkit is a platform to develop Mulesoft connector. Devkit is very powerful tool to develop extreme complex connector or simple connector.
Here are few steps to develop Mulesoft connector.
1) Create project from anypoint studio
2) Select SDK Based connector. This selection supports standalone java as well as REST based API. Once you select this selection below window will come. Name your connector project, select working directory and then click next
3) Now next step you need to select maven Group Id and Artifact Id and click next.
4) Next step you need to select icon and logo for your connector then click finish.
After clicking finish connector project will generate.
Two java files are generated in your connector project. Here my project name is Vanrish, so it generated VanrishConnector.java and ConnectorConfig.java.
In this code snippet annotation defines your connector name and display name. In above annotation “name” is for connector name and “friendlyName” will display connector name once you install this connector in Anypoint studio. This annotated class is main class for creating connector
In 2nd line we are initiating config class to add all configuration related with this connector.
If you are adding any method to execute this connector you need to define your method with @Processor annotated method.
Here are annotation definition for connector @Configurable — Allow to configure this field @Optional —This field is not mandatory @Default —This is providing default value for field
Here is full code snippet
package org.mule.modules.vanrish.config;
import org.mule.api.annotations.components.Configuration;
import org.mule.api.annotations.Configurable;
import org.mule.api.annotations.param.Default;
import org.mule.api.annotations.param.Optional;
@Configuration(friendlyName = "Configuration")
public class ConnectorConfig {
/**
* Vanrish API Url
*/
@Configurable
@Optional
@Default("https://platform.vanrish.com/api")
private String apiUrl;
@Configurable
@Optional
@Default("v1")
private String apiVersion;
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
}
In advance connector writing you can create client java class and use above apiURL and version to access api method and execute to get result.
Now to build this project in Anypoint studio, you need to select project and right click. This action will pop up option window. Here in this window you need to select Anypoint Connector then click Build connector.
Steps — Right Click on project –>Anypoint Connector –> Build Connector
Here it is shown in the picture below
This action will build your connector.
Follow the same steps to install your connector into Anypoint studio. Steps — Right Click on project –> Anypoint Connector –> Install or Update
This action will install your connector into Anypoint studio.
After installing your connector,you can search your connector name into Anypoint studio.
Connector Testing
you can create small flow in Anypoint studio and test your connecotor.
Mulesoft connector is the backbone of mulesoft flow. It receives or sends messages between Mule and one or more external sources, such as files, databases, or Web services. It also acts as message sources by working as inbound endpoints, they can act as a message processor that performs an operation in middle of a flow, or they can fall at the end of a flow and act as the recipient of the final payload data.
Mulesoft connectors are either endpoint-based or operation-based. Endpoint-based follow one-way or request-response exchange patterns. Operation-based connectors are based on information exchange pattern.
There are number of connector available in anypoint studio but some time the connector available is not able to satisfy company specific requirement. Own connector is a good option to explore whether we need a connector with a specific functionality or want to connect to a system without a pre-built connector.
If you are building your own connector you need to setup your development environment inside your mulesoft anypoint studio.
Make sure you enable maven configuration inside your anypoint studio and install Devkit for Mulesoft connector
1. Installation and Configuration of Maven Steps to enable Maven setting inside Anypoint studio.
a) Studio –>Help –> Install New Software
b) In Available Software window
Work with –>Anypoint Addons Update Site
c) Now you need to select Maven Tools for Mule
d) Click Next button and Then Finish.
This will install maven plugin into your Anypoint studio
Validate your maven plugin installation
Got to Window –> Preferences
you can find maven link under Anypoint Studio tab
configure maven in your Anypoint studio
set maven installation directory and enter your maven command
Click Test Maven configuration. You will get green check. Now you all set for maven configuration
2. Installation of Anypoint Devkit Plugin Steps to get Anypoint DevKit Plugin
a) Studio –>Help –>Install New Software
b) In Available Software window Please select Anypoint DevKit Update site
c) Now you need to select Anypoint Devkit Plugin
d) Click Next button and Then Finsh.
This will install Anypoint Devkit Plugin into your Anypoint studio
Validate your Devkit plugin installation
Go to File — New in Anypoint studio
You will find two new options for Anypoint Connector
a) Anypoint Connector Project
b)Anypoint Connector Component
Now you all set to develop your own connector.
In my next blog I will write how to build and deploy your own connector.