Skip to main content

#Vars0 人正在讨论

Hello lads

 

I have added an Untill Success object into flow and I whenever there is an error, within On Error Continue object, I save the value of error object to a variable(error_object var), run few processes and then I would like to raise an error manually using the same error type and error message that I saved previously into a variable.

The problem is: the raise error component does not allow to use value from variables. It requires hard coded strings.

I would need something like #vars.error_object.errorType.

According to the documentation it is not possible.

 

Could anyone suggest a workaround for this?

2 个回答
  1. Anurag Sharma (Nagarro) Forum Ambassador
    2024年5月14日 12:23

    Hello @Kleber Bueno​ 

     

    In MuleSoft, the raise-error component does indeed require hard-coded values for the type and description

    attributes, which can be limiting when you need to dynamically raise errors based on variable content. However, there's a workaround using the scripting capabilities of MuleSoft, specifically with DataWeave to achieve dynamic error handling.

     

    It sounds like you are already capturing and storing the error details in a variable (error_object). Make sure that this variable contains all necessary information, such as errorType and errorMessage.

    instead of raise component you can use dataweave runtime functions.

     

    check this - DataWeave similar functions as the Raise component https://docs.mulesoft.com/dataweave/2.4/dw-runtime

     

    https://docs.mulesoft.com/dataweave/2.4/dw-runtime-functions-fail

    .

0/9000

I am trying to write CSV file using SFTP write .I have given the path in the working directory.Test connection is success. But still it throws error like

Message        : Exception occurred while trying to change working directory to /abc/xyz/....

Element        : file_list_exampleFlow/processors/2/processors/5 @ file_list_example:file_list_example.xml:59 (Write)

Element XML      : <sftp:write doc:name="Write" doc:id="6342add8-97ea-4f33-a737-0b63eec33fdb" config-ref="SFTP_Config" path="#vars.file_name" mode="CREATE_NEW"></sftp:write>

Error type      : MULE:UNKNOWN

 

Please suggest.

2 个回答
  1. 2019年12月27日 15:31

    upgrade your sftp connector to 1.3.4. it worked for me

     

    <dependency>

    <groupId>org.mule.connectors</groupId>

    <artifactId>mule-sftp-connector</artifactId>

    <version>1.3.4</version>

    <classifier>mule-plugin</classifier>

    </dependency>

0/9000

I tried to use <on-error ref="test-error-handler"/> to reference the error handling strategy in the Mule Application. I created new test application using Anypoint Studio v7.17 and I encountered that this element causes compilation errors. Has anyone also encountered such a problem and know how to resolve this?

 

<app.runtime>4.6.2</app.runtime>

<mule.maven.plugin.version>4.2.0</mule.maven.plugin.version>

 

Error Message:

[ERROR] Failed to execute goal org.mule.tools.maven:mule-maven-plugin:4.2.0:process-classes (default-process-classes) on project common-extend-test: Fail to compile: Cannot invoke "org.mule.runtime.ast.api.ComponentParameterAst.getRawValue()" because the return value of "org.mule.runtime.config.internal.validation.AbstractErrorValidation.getErrorTypeParam(org.mule.runtime.ast.api.ComponentAst)" is null -> [Help 1]

 

Configuration XML:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd ">

<flow name="test-raml-main">

<http:listener config-ref="test-raml-httpListenerConfig" path="/api/*">

<http:response statusCode="#vars.httpStatus default 200">

<http:headers>#vars.outboundHeaders default {}</http:headers>

</http:response>

<http:error-response statusCode="#vars.httpStatus default 500">

<http:body>#[payload]</http:body>

<http:headers>#vars.outboundHeaders default {}</http:headers>

</http:error-response>

</http:listener>

<apikit:router config-ref="test-raml-config" />

<error-handler >

<on-error ref="test-error-handler"/>

<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="4a2c18e6-d4a4-4659-afb3-0108f1074b3c" >

<logger level="INFO" doc:name="Logger" doc:id="318a7585-7926-4dc6-b76a-5ffe72f392b2" />

</on-error-continue>

</error-handler>

</flow>

<error-handler name="test-error-handler" doc:id="c849264d-d1d4-4a06-b3a0-3b4e3cbf1e35">

<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="19e4b41a-b088-4d78-b40a-b6370718e943" type="EXPRESSION">

<logger level="INFO" doc:name="Logger" doc:id="f8acc841-b047-44ac-88fc-cfbc0b33e40f" />

</on-error-continue>

</error-handler>

<flow name="get:\test:test-raml-config">

<logger level="INFO" message="get:\test:test-raml-config" />

</flow>

</mule>

5 个回答
  1. 2024年6月11日 13:50

    Hi ,

    It looks like there is a reference to a common error handler and another 'on error continue' statement present, which is causing the error. Please remove it.

     

    current inside main flow test-raml-main

    <on-error ref="test-error-handler"/>

    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="4a2c18e6-d4a4-4659-afb3-0108f1074b3c" >

    <logger level="INFO" doc:name="Logger" doc:id="318a7585-7926-4dc6-b76a-5ffe72f392b2" />

     

    </on-error-continue>

    </error-handler>

     

    instead only have this

    <error-handler ref="test-error-handler" />

     

    Hi ,It looks like there is a reference to a common error handler and another 'on error continue' statement present, which is causing the error. Please remove it. 

0/9000

I need to pass a list of unique ids to a stored procedure. The expectation is that the procedure would return all data rows from a table that are related to any of the given ids. Another approach would be to foreach over the list and call the procedure for each ID, but I'd rather not take the inevitable performance hit.

 

In other langauges this could be accomplished by passing in a table valued parameter and joining against it in the stored proc. I have found the documentation for utilizing user defined types for Oracle databases [here](https://docs.mulesoft.com/mule-runtime/3.8/database-connector-reference# jdbc-user-defined-data-types-udt) and [here](https://docs.mulesoft.com/mule-runtime/3.8/database-connector# passing-user-defined-data-types-to-stored-procedure) but have not been able to find any documentation regarding how to accomplish the same thing for SQL server.

 

I've tried various definitions based on the above documentation in the off chance that the same approach would work with SQL Server and just wasn't documented, but that hasn't been the case. I usually get an error like the following:

 

com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.

 

I believe this means the driver doesn't know how to translate the array in Mulesoft into a user defined table type in the database. Is it possible to use TVPs with SQL Server in Mulesoft?

6 个回答
  1. 2020年10月15日 21:38

    I couldn't got the sample code working until I added the java module to the solution. Once this is added it works/doesn't through and errors.I couldn't got the sample code working until I added the java module to the solution. Once this is added it works/doesn't through and errors.

0/9000
6 个回答
0/9000

Hi, I'm trying to do an LDAP search and I'm using this expression to determine what i search for in the filter:

 

sAMAccountName=#vars.person.rows[0]systemIdentifications.content.iamUserid.content]

 

Is there anything obviously wrong with this expression that Ive missed?

 

This is what it looks like in the xml: <ldap:search-one doc:name="Search one" doc:id="f50e7c19-9eb9-426b-9b71-d3d0ae557dc5" config-ref="LDAP_Configuration" baseDn="#payload.baseDN" structuralObjectClass="person" filter="#[sAMAccountName=#vars.person.rows[0]systemIdentifications.content.iamUserid.content]]"/>

2 个回答
0/9000

<email:send doc:name="Send" doc:id="2da07ee3-13c9-4b88-92f1-2459deb46f50" config-ref="SMTP" fromAddress="123@gmail.com" subject="Queue Alert">

 

<email:to-addresses>

 

<email:to-address value="abc@gmail.com" />

 

</email:to-addresses>

 

<email:body contentType="text/plain">

 

<email:content><![CDATA[#vars.ListofQueues]]></email:content>

 

</email:body>

 

</email:send>

 

But the output I am receiving in email is ’ .

 

Array List have : [QueueNAme : abc Size = 0, QueueName : efg Size = 0]. The Array size is dynamic.

1 个回答
0/9000

<?xml version="1.0" encoding="UTF-8"?>

 

<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:http="http://www.mulesoft.org/schema/mule/http"

xmlns="http://www.mulesoft.org/schema/mule/core"

xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd

http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">

<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="3e081917-1381-4106-a2fa-a9c4d8180881" >

<http:listener-connection host="0.0.0.0" port="8081" />

</http:listener-config>

<db:config name="Database_Config" doc:name="Database Config" doc:id="4be42af6-7e1c-4b97-b5ed-6718d5aaf398" >

<db:my-sql-connection host="mudb.learn.mulesoft.com" port="3306" user="mule" password="mule" database="training"/>

</db:config>

<flow name="training4-american-wsFlow" doc:id="0fe44c96-8928-4eed-83ae-937a742fc24e" >

<http:listener doc:name="Listener" doc:id="43e1d8fb-4de1-4173-8ec9-5666c480529b" config-ref="HTTP_Listener_config" path="/flights"/>

<db:select doc:name="Select" doc:id="74c0406a-9130-445f-95f5-5a4ff5b01fee" config-ref="Database_Config">

<db:sql >SELECT *

FROM american</db:sql>

</db:select>

</flow>

</mule>

12 个回答
  1. 2021年1月16日 09:07

    Hello @Srinivas Pachari​ ,

     

    your welcome, just for other developers I am describing the fix of your issue.

     

    1. recreated the HTTP configurations
    2. added new HTTP listener with some more configurations for response
    3. in transform message just after db connector used output application/json

     

    Thanks,

    Anurag Sharma

0/9000

I am mocking the salesforce but still, i think it's calling to direct endpoint so i am getting this error.

java.lang.AssertionError: at file: [case-implementation-test-suite.xml], line: [424]

Expected: 200 as Number {encoding: "UTF-8", mediaType: "application/java; charset=UTF-8", mimeType: "application/java", class: "java.lang.Integer"}

   but: 500 as Number {encoding: "UTF-8", mediaType: "application/java; charset=UTF-8", mimeType: "application/java", class: "java.lang.Integer"} at (root)

 

at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)

 

can any one kindly advice on this.

 

Regards,

10 个回答
  1. 2020年11月24日 11:34

    Hi @Mulesoft C​ 

     

    Try to use readUrl while passing the payload, and Mime-type as application json:

    output application/json

    ---

    readUrl('classpath://updatepayload.json','application/json')

    Hi @Mulesoft C​ Try to use readUrl while passing the payload, and Mime-type as application json:output application/json---readUrl('classpath://updatepayload.Regards,

    Abhishek Bathwal

0/9000

Hi,

 

I try to build a Mule SDK connector in which i want to initialize variables. I see i can use The Result Object and output a target variable in the advanced tab, but is there an option to for example make additional fields as variables in the general tab? For example i will need a @Parameter field as a variable to be accessible from the flow in other connectors? Is this possible in Mule SDK, so far i have not found anything in that direction...

2 个回答
0/9000