0

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.

star
  • 1,493
  • 1
  • 28
  • 61
  • What exactly is that inside the error handling that you want to reuse? – aled Mar 21 '20 at 17:05
  • set of error message , processor and logger dataweave which is inside the errorHandling (200,201,400,500,406,405 etc). Basically part of mule flow always going to be same for all api's – star Mar 21 '20 at 23:08

2 Answers2

1

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.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Alex
  • 4,457
  • 2
  • 20
  • 59
  • Thanks @Alex. `https://simpleflatservice.com` page not opening. Could you help enabling it. Thanks for your reply. – star Mar 21 '20 at 23:15
  • you mean convert the resuable flow as jar file and put it in the repo to use overall?. how it is useful compare with XML SDK. Thinking which one is easy and less timing consuming and benefit more. Any Idea? – star Mar 21 '20 at 23:32
  • @Alex please note in my answer the recommended way to implement shared flows. – aled Mar 24 '20 at 01:00
  • @Aled Yes i gonna use recommended way working on XML SDK. checking out other ways too indeed to know more ways.Thanks most of answering my questions fast and in next day- it saves lot of time. – star Mar 24 '20 at 22:56
  • 1
    Clarification: my previous comment was intended for people that import flows from JAR files, which is the method that @Alex described in his answer. There is a recommended way to implement that, that I mentioned in my answer. Using the XML SDK is a different method. – aled Mar 25 '20 at 02:37
1

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.

aled
  • 21,330
  • 3
  • 27
  • 34
  • Thanks @Aled you got my question right. yes i want part of mule flow to be converted in to Resuable connector/component. Im looking out the possible ways to do it. Will explore `XML SDK`. Thanks for the detailed response. – star Mar 21 '20 at 23:27