Skip to main content

#Mule 40 discutindo

Hello,

 

i'm fetching the alert email template from DB and Message_Template column will have multiple and different properties placeholders and how will i replace them with the values in a variable emailPropertiesValues using DWL. 

 

In a nutshell i have to replace all the available property placeholders in Muessage_Template with their correspoinding from the emailPropertiesValues key values. Keys can be dynamic and need to be same for other request.

 

Input (DB response):

{  "Application_Name": "Test Applicatioin",  "Condition_Priority": "ERROR",  "Message_Template": "FAILURE\n This is a notification email to inform you about failure in the ${cloudhubEnvironment}  ${appName} with transaction ${transactionId} \n\nHello,\nYou are receiving this alert because:\nThe ${appName} application has a new ${priority} notification with a failure message.\n\n------------------\nFAILURE TEXT\n------------------\n\nError Type: ${errorType}\n\n--------------\nCONTEXT\n--------------\n\nServer : CloudHub\nTime Stamp: ${timeStamp}\n. ${descriptionText}",  "Subject": "Mule ERROR",  "Created_At": "2023-11-20T10:21:26.93",  "Region": "ps-vr2",  "Source": "Applications"}

emailPropertiesValues variable and its values:

{  "transactionId": "cbd0d3049ae8-23-safd-23",  "appName": "demo-qa-app",  "descriptionText": "descriptionText",  "errorType": "errorType",  "alertType": "alertType",  "timeStamp": "2023-11-06T09:31:32.879+05:30",  "cloudhubEnvironment": "dev-ps"  "priority": "ERROR"}

 

expected output:

{  "Application_Name": "Test Applicatioin",  "Condition_Priority": "ERROR",  "Message_Template": "FAILURE\n This is a notification email to inform you about failure in the dev-ps  demo-qa-app with transaction cbd0d3049ae8-23-safd-23 \n\nHello,\nYou are receiving this alert because:\nThe demo-qa-app application has a new ERROR notification with a failure message.\n\n------------------\nFAILURE TEXT\n------------------\n\nError Type: errorType\n\n--------------\nCONTEXT\n--------------\n\nServer : CloudHub\nTime Stamp: 2023-11-06T09:31:32.879+05:30\n. descriptionText",  "Subject": "Mule ERROR",  "Created_At": "2023-11-20T10:21:26.93",  "Region": "ps-vr2",  "Source": "Applications"}

Appreciate your help on this.

 

Thanks

 

 

 

#Mule 4

11 respostas
  1. 12 de dez. de 2023, 14:28

    I have removed everything from your code base and added only one transformation and it will work. Please make further changes according to your requirements.

     

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

     

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

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

    xmlns:kafka="http://www.mulesoft.org/schema/mule/kafka" 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/kafka http://www.mulesoft.org/schema/mule/kafka/current/mule-kafka.xsd

    http://www.mulesoft.org/schema/mule/eilog http://www.mulesoft.org/schema/mule/eilog/current/mule-eilog.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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">

    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="1df86740-6b8a-42c8-b117-2a4227a3c108" >

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

    </http:listener-config>

    <flow name="main-flow" doc:id="de8c026d-5ae8-4d1e-872e-9ac99c836a03">

    <http:listener doc:name="Listener" doc:id="54fd0ac4-ed66-4494-acd0-af88140846a4" config-ref="HTTP_Listener_config" path="/email"/>

    <ee:transform doc:name="Transform Message" doc:id="eebf9bab-cc01-4186-8bce-965c3341b483" >

    <ee:message >

    <ee:set-payload ><![CDATA[

    %dw 2.0

    output application/json

    var dbselectoutput = readUrl("classpath://db-response.json","application/json")

    ---

    payload map ((item, index) ->

     

    dbselectoutput update {

    case .Message_Template -> namesOf(item.customProperties) reduce ((item1, accumulator=dbselectoutput.Message_Template) ->

    accumulator replace ("\$" ++ "{$(item1)}") with item.customProperties[item1])

    }

     

     

    )]]></ee:set-payload>

    </ee:message>

    </ee:transform>

    </flow>

    </mule>

     

0/9000
Worker(44.***.**.**): Your application has failed with exception java.lang.IllegalStateException: com.mulesoft.ch.services.agent.muleAgent.MuleAgentException: {"type":"class java.lang.IllegalArgumentException","message":"There was an error on the Mule Runtime while deploying the application test-api. Error: Failed to deploy from URI: file:/tmp/mule-received-artifact-3234148462539683444/test-api.jar. ArtifactNotFoundException: Could not find artifact org.mule.connectors:mule-http-connector:pom:1.7.1"}

 

Thanks in advance.

 

#CloudHub​ #Mule 4​ #HTTP/HTTPS​ 

3 respostas
  1. 22 de dez. de 2022, 05:51

    When you are exporting the package from Studio make sure to check the bottom-most check box (in the "Export" dialog). Verify that your project's jar file size is in megabytes (instead of KB).

    This would indicate that you bundles all the dependency modules that your project needs. Then try deploying that to CLoudHub..and it should work.

     

    And also please check your mule-artifact.json file is correctly alligned in the jar.

0/9000

Hi - I'm calling a web service url with HTTP Request component. However i have to generate the soap headers manually. Its working fine in postman. But now to make it work in dwl i'm facing transformation issue while concatenating xml paylod with soap headers.

 

payload:

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

<man:submitDocument xmlns:man="http://www.t.com/ws/integration/toolkit/2011/05/management">

<Document xmlns:ns2="http://www.t.com/ws/integration/toolkit/2011/05" ns2:name="">

<Attributes>

<Attribute name="locale">en</Attribute>

<Attribute name="largegraph">true</Attribute>

<Attribute name="mode">T-XML</Attribute>

<Attribute name="version">http://www.t.com/ws/tee800/2009/01</Attribute>

</Attributes>

<Content>

<ExportQuery xmlns:ns1="http://www.t.com/ws/so800/2009/01" ns1:name="">

<quer:query xmlns:quer="http://www.t.com/ws/integration/query" alias="Query752BAE88-55BD-11E2-8B1D-CDAFDC756D0C" preventDuplicates="false" projectedClass="Application">

<quer:subQueries/>

<quer:projections>

<quer:projection alias="FirstName">

<quer:field path="Candidate,FirstName"/>

</quer:projection>

<quer:projection alias="MiddleName">

<quer:field path="Candidate,MiddleInitial"/>

</quer:projection>

<quer:projection alias="LastName">

<quer:field path="Candidate,LastName"/>

</quer:projection>

<quer:projection alias="IsSubmissionExpired">

<quer:field path="Applications,IsSubmissionExpired"/>

</quer:projection>

</quer:projections>

<quer:projectionFilterings/>

<quer:filterings>

<quer:filtering>

<quer:or>

<quer:equal>

<quer:field path="CSWLatestStep,Name"/>

<quer:string>Pre-Employment Process</quer:string>

</quer:equal>

<quer:equal>

<quer:field path="CSWLatestStep,Name"/>

<quer:string>Terminal Pre-Employment Process</quer:string>

</quer:equal>

</quer:or>

</quer:filtering>

<quer:filtering>

<quer:equal>

<quer:field path="CSWLatestStatus,Name"/>

<quer:string>Move to Hired</quer:string>

</quer:equal>

</quer:filtering>

<quer:filtering>

<quer:equal>

<quer:field path="Candidate,InternalApplication"/>

<quer:string>0</quer:string>

</quer:equal>

</quer:filtering>

</quer:filterings>

<quer:sortings/>

<quer:sortingFilterings/>

<quer:groupings/>

<quer:joinings/>

</quer:query>

</ExportQuery>

</Content>

</Document>

</man:submitDocument>

dwl

%dw 2.0

output application/xml

var username = "test"

var password = "test"

 

var soapPayload = read('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken wsu:Id="Username"><wsse:Username>' ++ username as String ++ '</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' ++ password as String ++ '</wsse:Password></wsse:UsernameToken></wsse:Security><add:Action xmlns:add="http://www.w3.org/2005/03/addressing">http://www.t.com/ws/integration/toolkit/2005/07/action/export</add:Action><add:ReplyTo xmlns:add="http://www.w3.org/2005/03/addressing"><add:Address>http://www.t.com/ws/integration/toolkit/2005/07/addressing/queue</add:Address></add:ReplyTo><add:MessageID xmlns:add="http://www.w3.org/2005/03/addressing">RE</add:MessageID></soap:Header><soap:Body>' ++ payload ++ '</soap:Body></soap:Envelope>', "application/xml")

---

soapPayload

 

error:

You called the function '++' with these arguments:

1: String ("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soa...)

2: Object (do {ns man http://www.t.com/ws/integration/toolkit/2011/05/management---{man#...)

 

But it expects one of these combinations:

(Array, Array)

(Date, Time)

(Date, LocalTime)

(Date, TimeZone)

(LocalDateTime, TimeZone)

(LocalTime, Date)

(LocalTime, TimeZone)

(Object, Object)

(String, String)

(Time, Date)

(TimeZone, LocalDateTime)

(TimeZone, Date)

(TimeZone, LocalTime)

 

6| var soapPayload = read('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken wsu:Id="Username"><wsse:Username>' ++ username as String ++ '</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' ++ password as String ++ '</wsse:Password></wsse:UsernameToken></wsse:Security><add:Action xmlns:add="http://www.w3.org/2005/03/addressing">http://www.t.com/ws/integration/toolkit/2005/07/action/export</add:Action><add:ReplyTo xmlns:add="http://www.w3.org/2005/03/addressing"><add:Address>http://www.t.com/ws/integration/toolkit/2005/07/addressing/queue</add:Address></add:ReplyTo><add:MessageID xmlns:add="http://www.w3.org/2005/03/addressing">RE</add:MessageID></soap:Header><soap:Body>' ++ payload ++ '</soap:Body></soap:Envelope>', "application/xml")

^^^^

Trace:

at main::++ (line: 6, column: 19)

at main::++ (line: 6, column: 392)

at main::++ (line: 6, column: 414)

can someone help me out pls.

 

#Mule 4​ #DataWeave 2​ #soap #WEB SERVICES​ 

3 respostas
  1. 8 de dez. de 2022, 02:00

    Below script will help you.

     

    %dw 2.0

    output application/xml

    var username = "test"

    var password = "test"

    var soapPayload = read('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken wsu:Id="Username"><wsse:Username></wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"></wsse:Password></wsse:UsernameToken></wsse:Security><add:Action xmlns:add="http://www.w3.org/2005/03/addressing">http://www.t.com/ws/integration/toolkit/2005/07/action/export</add:Action><add:ReplyTo xmlns:add="http://www.w3.org/2005/03/addressing"><add:Address>http://www.t.com/ws/integration/toolkit/2005/07/addressing/queue</add:Address></add:ReplyTo><add:MessageID xmlns:add="http://www.w3.org/2005/03/addressing">RE</add:MessageID></soap:Header><soap:Body></soap:Body></soap:Envelope>', "application/xml")

    ---

    soapPayload update {

    case .Envelope.Header.Security.UsernameToken.Username -> username

    case .Envelope.Header.Security.UsernameToken.Password -> password

    case .Envelope.Body -> payload

    }

0/9000

Additionally, the things I tried,

After Executing the MMA Tool on my project (Mule 3), I tried to replace the unsupported CXF component with Web Service Consumer (Which I think is the only component that should suffice the requirement.

While doing so, I am encountering an error in logs that talks about below:

Error reading XMLStreamer: Undeclared namespace prefix "soapenv"

 

Well, the CXF component has a field for Inbound Attributes Namespace to define the information but the same I didn't see in Web Service Consumer.

 

Could you please guide me @Akshata Sawant​ @Gaurav Dhimate​ 

@Manish Yadav​ @Abhishek Bathwal​ @Jitendra Bafna​ @Vikalp Bhalia​ @Vikalp Bhalia​ 

 

#Mule 3​ #Mule 4​ #Mule Migration Assistant (MMA)​ #Migration​ #Unsupported Components

3 respostas
0/9000

I have below input payload, the expected output should be swapped

 

Input:

[{

"name" : "A",

"id" : 1

},

{

"name" : "B",

"id" : 2

}]

output:

[{

"A" : "name",

1 : "id"

},

{

"B" : "name",

2 : "id"

}]



#DataWeave 2​ #Mule 4​ 

6 respostas
0/9000

how to convert .csv file to .zip file in Mule4. Is there any custom connectors ? Can someone let me know if there are better solution.

 

Note: java code is not preferred.

 

#DataWeave 2​ #Mule 4​ #DataWeave 1​ 

8 respostas
  1. 11 de fev. de 2020, 19:08

    if multiple files, I will make use of Archive operation instead of Compress. For entries, you can follow below

     

    {(payload.data map(value, index) -> {

    (value.fileName) : value.payload write "application/csv"

    }

    )}

     

    where you want to write set of entries. Above command will result to

    {

    "test1.csv" : [<content>],

    "test2.csv" : [<content>]

    }

0/9000

For ex:

i have below data in gsheet:

 

oppID status date

789 active 20/12/24

123 active 20/12/24

456 inactive 21/12/24

 

Now if a user want to update oppid 123 as inactive. how to do that dynamically?

i don't want to fetch whole data from gsheet and check in which row the oppid is. Is there any search mechanism i can have to directly search in gsheet and update the row

 

#Mule 4​  #DataWeave 2​ #Connectors​ 

2 respostas
  1. Shekh Muenuddeen (NTTData) Forum Ambassador
    25 de set. de 2024, 14:23

    As per me there are two ways to do it

    • Using MuleSoft DataWeave - download excel , load into DataWeave and update row then DataWeave output will excel file and upload excel file.

     

    Read - Excel file

    %dw 2.0

    var myInput = readUrl("classpath://ourBugs.xlsx", "application/xlsx")

    output application/json

    ---

    myInput."Data"

    Generate Excel file

    %dw 2.0

    output application/xlsx header=true

    ---

    {

    Data: payload

    }

    • Read excel file using java or other scripting language which MuleSoft Supports. Using this way it might be easy to update excel file.

    Example

    https://dzone.com/articles/how-to-color-excel-file-using-mulesoft-1

0/9000

Can someone please help me with the best way to implement the above scenario. I need to fetch 50k rows from snowflake once a month and upload it as as csv file into target system. I'm able to fetch few 100s row at once and convert into csv and upload it to target. But i wanted to understand ways to do the same process for 50k rows. Thanks in advance.

#snowflake #mule4

1 resposta
  1. 30 de jun. de 2024, 03:21

    You can use the select on the snowflake connector (or JDBC connector I'd imagine if snowflake allows JDBC connections), I would look at any settings that impact streaming for that.. like fetch size (this will avoid too many round trips as the default is set to 10 I believe) and the repeatable vs non repeatable streaming stuff (as I presume you only need to access the stream of rows once!) and then you can look at dataweave's streaming support: https://docs.mulesoft.com/dataweave/latest/dataweave-streaming

    Essentially you'll want to do your transformation to CSV, set the deferred=true on the output directive and then call your write to remote CSV file operation on whichever connector you're using. That makes the dataweave do a "from one stream to another" deferred mode of operation, which should avoid unnecessary I/O..

     

    I'd be doing tests locally with something like visual VM hooked up to the mule java process to make sure memory isn't blowing out or something - test with suitably large test cases to see what's going on, and you can try using the file connector in lieu of the FTP/SFTP or whatever you're going to use initially to see what's going on, then swap to the real connector and test again..

0/9000

As per the documentation Azure Key Vault Properties Provider 2.0 Reference - Mule 4, I could configure the Client ID, Client Secret and Tenant ID as environment variables

AZURE_CLIENT_ID, AZURE_CLIENT_SECRET and  AZURE_TENANT_ID.

 

But how to configure "Key Vault Name" dynamically?

 

I bumped in to a documentation which says it as a limitation. Can anyone confirm this? or is there a way we can provide it dynamically?

 

#Mule 4​ #azure-key-vault-properties-provider

2 respostas
0/9000

Hi Team,

 

I'm fetching couple of details from anypoint platform using rest apis ( ~10k api call) in parallel for-each. i'm aggregating the payload and inserting these records into MySql DB.

 

while executing i'm seeing below message in log and app is taking bit long time to execute. Just thinking is there a way to enable streaming in this flow.

 

flow:

-> app -> call platform rest api (parallel foreach, size 20) -> aggregate payload -> bulk insert to DB (wraped on for-each, size 1000)

 

INFO  2023-11-06 16:31:25,100 [[MuleRuntime].uber.35: [cloudhub-api-mgmt].api-mgmt-mainflow.BLOCKING @98f571b] [processor: bulk-upsert-api-to-db/processors/0/processors/0/errorHandler/0/processors/1; event: ccc94a30-7c91-11ee-bafa-bcd07412b57e] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: [TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@72a18227', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@926a8f3', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@4f575f03', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@75a51fa2', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@beb0b8b', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@37b65b35', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@426cb587', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@1fe9ea67', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@4c0d1d42', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider@49e79805', dataType: 'SimpleDataType{type=org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider, mimeType='application/json; charset=UTF-8'}'], TypedValue[value: 'org.mul

appreciate any suggestions.

 

#Mule 4​ 

2 respostas
0/9000