Convert Resuable ErrorHandling flow in to connector/component in Mule4

308 Views Asked by At

I'm Using Mule 4.2.2 Runtime. We use the errorHandling generated by APIKIT and we customized it according to customer requirement's, which is quite standard across all the upcoming api's.

Thinking to convert this as a connector so that it will appear as component/connector in palette to reuse across all the api's instead copy paste everytime.

Like RestConnect for API specification which will automatically convert in to connector as soon as published in Exchange ( https://help.mulesoft.com/s/article/How-to-generate-a-connector-for-a-REST-API-for-Mule-3-x-and-4-x).

  1. Do we have any option like above publishing mule common flow which will convert to component/connector?

  2. If not, which one is the best way suits in my scenario

    1) using SDK

    https://dzone.com/articles/mulesoft-custom-connector-using-mule-sdk-for-mule (or)

    2) creating jar as mentioned in this page

    [https://www.linkedin.com/pulse/flow-reusability-mule-4-nagaraju-kshathriya][2]
    

Please suggest which one is best and easy way in this case? Thanks in advance.

2

There are 2 best solutions below

1
aled On BEST ANSWER

Using the Mule SDK (1) is useful to create a connector or module in Java. Your questions wasn't fully clear about what do want to encapsulate in a connector. I understand that you want is to share parts of a flow as a connector in the palette, which is different. The XML SDK seems to be more inline with that. You will need to make some changes to encapsulate the flow elements, as described in the documentation. That's actually very similar to how REST connect works.

The method described in (2) is for importing XML flows from a JAR file, but the method described by that link is actually incorrect for Mule 4. The right way to implement sharing flows through a library is the one described at https://help.mulesoft.com/s/article/How-to-add-a-call-to-an-external-flow-in-Mule-4. Note that this method doesn't create a connector that can be used from Anypoint Studio palette.

5
Alex On

From personal experience - use common flow, put it to repository and include it as dependency to pom file. Even better solution - include is as flow to the Domain app and use it alone with your shared https connector.

I wrote a lot of Java based custom components. I liked them a lot and was proud of them. But transition from Mule3 to Mule4 killed most of them. Even in Mule4 Mulesoft makes changes periodically which make components incompatible with runtime.