Author: Aditya Veer
CloudHub connector in Anypoint Studio helps us to interconnect cloudhub with mule project. It helps us by allowing us to create notifications, to list all or specific (i.e. READ / NOT READ) notifications, and to get information about the applications deployed on Cloudhub. This connector connects us with cloudhub.
Add a CloudHub connector in Anypoint studioÂ
- First, you have to go on your ‘ Mule Palette.’ Then you have to select ‘ Search in Exchange ’ (Here you can add the dependencies by searching them in Exchange)
- Add your Anypoint Platform account
- Search for the CloudHub connector – Mule 4, Published by ‘ MuleSoft’
- Select it and Add it
- Click on ‘Finish.’ The connector will be added in the ‘ Mule Palette’
- In cloudhub connector you can see five different connectors, each of this connector has different functionality
- Create Notification
- Get Application
- List Application
- List Notification
- Mark Notification
Configure your Cloudhub connector
- Move to ‘ Global Elements ’ and click on ‘ Create ’
- Expand the ‘ Connector Configuration ’ and there you can see the ‘CloudHub Config ’
- Properties required for CloudHub Connector are
- Username
- Password
- Environment
- Enter your Username and password of Anypoint Platform and wait a few seconds for the cloudhub environment then you can select the environment. Then test the connection
Functionality Of CloudHub Connector
- Create Notification
- This connector helps us to send alert notifications. It sends a notification to the domain for which the application is currently deployed. The notification which we are sending has three priority ERROR, INFO, WARN
- Drag and drop the ‘ HTTP Listener ‘ , ‘ Select ‘ from database module , ‘ Transform ’ connectors from the ‘ Mule Palette ’ and configure them
- Add a ‘ Create Notification ‘ and Name it as ‘ SUCCESS Create Notification ‘
- Select the ‘ Connector Configuration ’ which we have created. In the domain select the application which you have deployed on cloudhub. Write a message in a message box
- In the ‘ Priority ’ expand the drop down
- Here select ‘ INFO ’
- Go to the ‘Runtime Manager ’ of Anypoint Platform and click on ‘ Alert ’ and then click on    ‘ + ’ symbol to create a new alert
- Enter all the details but be sure to select the same ‘ Application ’ and ‘ Priority ’as you have selected in Anypoint Studio. In the ‘ Recipients ‘ section add the email ids of people to send the email
- Click on submit your ‘ Alert ’ will be created
- Return to Anypoint Studio and in the flow go on ‘ Error handling ’ and add ‘ On Error Propagate ’ and in ‘ type ’ select ‘ ANY ’
- Add ‘ Create Notification ’ and rename it as ‘ ERROR Create Notification ’ inside ‘ On Error Propagate ’
- Configure it as we did earlier but change the message and the ‘ Priority ’ to error
- Create an ‘ Alert ’ for your error message but change the ‘ Priority ’ ERROR and click Submit
- Now you’re good to go. Run your project and hit the URL in the ARC. You will get success and an alert email will be sent to the email address which you have mentioned
- If suppose there is some error in the flow then the ‘ ERROR Create Notification ‘ will send us an alert email
- Get Application
- This helps us to get details of a specific application deployed on cloudhub. For retrieving an application only the name of that application is required
- Drag and drop the ‘ HTTP Listener ‘ , ‘ Get Application ‘ , ‘ Transform ’ connectors from the ‘ Mule Palette ’
- In the ‘ Domain ’ of ‘ Get Application ‘ select the application of which you want to see the details
- Add ‘ Transform ’ component and convert the data into json
- Now you’re good to go. Run your project and hit the URL in the ARC. You will get success
- List Application
- This helps us to list details of all applications deployed on cloudhub. While configuring this connector we have to specify the environment and through that environment details of applications are fetched
- Drag and drop the ‘ HTTP Listener ‘ , ‘ List Application ‘ , ‘ Transform ’ connectors from the ‘ Mule Palette ’
- Keep all the setting as default in ‘ List Application ‘
- Add ‘ Transform ’ component and convert the data into json
- Now you’re good to go. Run your project and hit the URL in the ARC. You will get success
- List Notification
- This helps us to list details of all notifications we have received on cloudhub. While configuring this connector we have to specify the domain (Name of application), Limit ,and status inorder to get notifications related to specific application
- Drag and drop the ‘ HTTP Listener ‘ , ‘ List Notification ‘ , ‘ Transform ’ connectors from the ‘ Mule Palette ’
- In the ‘ Domain ’ of ‘ List Notification ‘ select the application of which you want to see the notifications, ‘ Limit ’ tells us the count of notifications we want to see of a specific application and ‘ -1 ’ means all notification , ‘ Status ’ means which status notification you want to read i.e. ‘ UNREAD ’, ‘ READ ’,’ ALL ’
- Add ‘ Transform ’ component and convert the data into json
- Now you’re good to go. Run your project and hit the URL in the ARC. You will get success
- Mark Notification
- It helps us by marking a specific notification. Here marking is done in two ways that are ‘ UNREAD ’ or ‘ READ ’. Here we have to pass ‘ID’ of that specific notification and type of marking
- Drag and drop the ‘ HTTP Listener ‘ , ‘ Mark Notification ‘ connectors from the ‘ Mule Palette ’
- In ‘ Mark Notification ‘ pass id through ARC and mark its status as ‘ UNREAD ’ or ‘ READ ’
- Now you’re good to go. Run your project and hit the URL and pass the ‘ id ’ in body in json format in ARC. You will get success and message of that specific ‘ id ’ will be ‘ UNREAD ’