My Mule studio version is:
version: 3.4.0
buildDate: 201305141336
I am confused on the catch exception strategy... and maybe I need to use a different strategy. Basically I need to write data to a file. After the file write I want to send an email to indicate whether the write was successful or not. (Failure is most likely to happen if someone has the file open at write time). I originally tried putting an email in the catch exception block but what happened then was that I got both emails; the one in the catch block and the one at the end of the flow. I attempted to create a variable with the email subject in it and change the value out in the exception but it doesn't seem to do anything. I still get the email with the success message in it.
Does anyone have some suggestions on how to make this work? Ultimately, I just want to send a different email based on the file write success/failure. Here is my configuration. I have been causing the failure by opening the target file with Excel which locks the file.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<flow name="FileOpenExample" doc:name="FileOpenExample" >
<quartz:inbound-endpoint xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" jobName="fileOpenEx" cronExpression="0,30 * * ? * FRI" repeatInterval="0" repeatCount="2" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job/>
</quartz:inbound-endpoint>
<set-payload value="Some Sample File Data" doc:name="Set File Data"/>
<set-variable variableName="emailSubject" value="File Save Successful" doc:name="Variable"/>
<file:outbound-endpoint path="C:\Temp\IntegrationTesting" outputPattern="Attributes.csv" responseTimeout="10000" doc:name="File"/>
<set-payload value="This email was generated by a Mule process." doc:name="Set Email Body"/>
<smtp:outbound-endpoint host="mail1.newpig.com" to="${email.toList}" subject="#[emailSubject]" responseTimeout="10000" doc:name="EmailSuccess" />
<catch-exception-strategy doc:name="Catch Exception Strategy" enableNotifications="false">
<expression-transformer expression="#[emailSubject='Save Failed']" doc:name="Expression"/>
</catch-exception-strategy> </flow>
</mule>
This scenario seems to be more similar like an earlier post.
Here the flow is posting onto an out-bound and then continue with the flow, as the out-bound is an asynchronous in nature. There needs to be something which can make the flow wait and then based on the status proceed further.
You can find the earlier similar post and my answer at the following link.
Mule flow execution unexpectedly splits on error in SMTP sendout
Hope this helps.
Related
I am creating a new flow in mule 3.9 using http connector and gerenic data base connector to connect to snowflake to run a procedure.
There are no error in the code,i could see that the codeis running successfully but i am getting
the below error.
java.lang.OutOfMemoryError: GC overhead limit exceeded
I have updated the anypoint.ini file upgraded the memory to 10240 still it didnt work
i am using snowflake jar 3.13.3 for this project
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cdata-snowflake="http://www.mulesoft.org/schema/mule/cdata-snowflake" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/cdata-snowflake http://www.mulesoft.org/schema/mule/cdata-snowflake/current/mule-cdata-snowflake.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[call E2e_Change_User('nudayaku' ,'tan')]]></db:parameterized-query>
</db:stored-procedure>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
i have tried but parameterized query as well as dynamic way , but both were resulting in timout error.
I have run the same procedure from snowflake , i am getting the output in seconds.
Can some help me how to fix the issue
Appreciate inputs
Thanks,
Sidh
This is a know issue in Mule 3.9.0 to Mule 3.9.4. The solution is to upgrade to Mule 3.9.5.
Source: https://help.mulesoft.com/s/article/Store-procedure-calls-fail-in-mule-3-x-for-snowflake-database
I'm trying to get the client IP and socket of a UDP package and save it in a Flowvar variable using the MEL code
#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]
However this variable is always null, I have been able to make it work on TCP transport, does anyone know how to get the remote client address in UDP?
This is my XML file:
<mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:udp="http://www.mulesoft.org/schema/mule/udp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/udp http://www.mulesoft.org/schema/mule/udp/current/mule-udp.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
<udp:connector name="UDP" validateConnections="true" keepSendSocketOpen="true" doc:name="UDP" broadcast="true"/>
<flow name="udpFlow">
<udp:inbound-endpoint exchange-pattern="one-way" host="172.22.20.103" port="4040" connector-ref="UDP" responseTimeout="10000" doc:name="UDP" metadata:id="9260547c-3b58-4ebd-953e-fd3e7bb063f3"/>
<object-to-string-transformer doc:name="Object to String"/>
<set-variable variableName="source" value="#[message.inboundProperties.MULE_REMOTE_CLIENT_ADDRESS]" metadata:id="6a72ad72-167f-44da-9f3d-75143c5c0a2f" doc:name="Variable"/>
<set-payload value="#[flowVars.source] dice #[payload]" doc:name="Set Payload"/>
<echo-component doc:name="Echo"/>
</flow>
</mule>
UPDATE:
I solve the Address issue with the MEL code
#[message.inboundProperties['packet.address']]: #[message.inboundProperties['packet.port']]
Thanks to David Dossot for his help.
Use:
#[message.inboundProperties['packet.address']]
I'm trying to make WebMQ act synchronously in MULE in order to turn the message queue into a REST api for an internal project. Unfortunately, I know very little about MULE.
After a good bit of work, I started understanding the Request-Reply scope and tried to use the WMQ Connector with it, only to find out that WMQ only sends once the flow has ended.
I've tried putting the request into a different flow using VM to trigger it
but so far that just leads to it waiting forever on WMQ that will never happen.
I've also tried using VMs for back and forth:
But it seems to do the same thing as without, where it just ignores the input.
Now I know the input and output for the WMQ are working, as I previously setup a flow that used http to communicate with itself and let it know when a message went through.
What I essentially want is this, but using HTTP instead of AJAX
My latest, and perhaps closest attempt looks like thus:
The XML being:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" version="EE-3.6.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:test="http://www.mulesoft.org/schema/mule/test" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<wmq:connector channel="MAGENTO.SVRCONN" doc:name="WMQ Connector" hostName="[ip]" name="wmqConnector" port="1414" queueManager="MAGENTO" transportType="CLIENT_MQ_TCPIP" validateConnections="true" />
<vm:connector name="VM" validateConnections="true" doc:name="VM">
<vm:queue-profile maxOutstandingMessages="500">
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="Input">
<http:listener config-ref="HTTP_Listener_Configuration" path="/mq" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties.'http.query.params'.xml]" doc:name="Set Payload"/>
<logger message="Entering Request-Reply Payload: #[payload]" level="INFO" doc:name="Logger"/>
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_TriggerSend" />
<vm:inbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_Receive" />
</request-reply>
<logger message="Request-Reply has ended. Payload: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Send_Message">
<vm:inbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_Send"/>
<logger message="(Preparing to Dispatch) Payload: #[payload]" level="INFO" doc:name="Logger"/>
<wmq:outbound-endpoint queue="PUT_QUEUE" connector-ref="wmqConnector" doc:name="WMQ"/>
<logger message="Message presumably being dispatched after this log" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Receive_Message">
<wmq:inbound-endpoint queue="GET_QUEUE" connector-ref="wmqConnector" doc:name="WMQ_Receive" />
<logger message="Triggering Receive" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_TriggerReceive" />
</flow>
</mule>
Which almost works, but it hangs indefinitely without sending a response back to the HTTP server. Setting the vm:inbound-endpoint in the Request-Reply flow to one-way keeps it from hanging, but doesn't send the new payload that's been received, but instead the previous payload (as if it's being skipped over).
Any help at all would be greatly appreciated!
If I understood correctly you are just trying to expose a request on a queue and a response on a well known queue as a REST api.
There is no need of VM queues there, and neither request-reply elements as the JMS transport can simulate the request response exchange pattern.
JMS queues are just one way. You have to necesarily reply on a different queue. The logic behind a request-response scenario is an outbound-endpoint that having an outbound property: MULE_REPLYTO. This property should be set with the name of your well known reply to queue: GET_QUEUE (if no such header is provided a temporary queue will be created).
The MULE_REPLY to header will become the standard JMSReplyTo when the mesasge is received at the service. The service has to honor this header sending the reply back to that queue. If the service is implemented on Mule this will happen automatically, otherwise it might not happen. You should double check its being honored.
If you want to use a request-reply scope with to one-way endpoints rather than one request-reponse endpoint, it is fine, should work the same but with more code.
Making an Asynchronous datasource Synchronous can indeed be tricky. But I don't really see an issue with your request-reply strategy.
Try to use an request-reply with WMQ endpoint on both sides. Then monitor the queues and see that the message and reply arrives as they should. Do you use the same queue for the request and the reply? The simplest scenario would be to use different ones, is that possible for your use-case?
I have my test flow successfully querying an imap inbox. I'm trying to capture the attachments and save them to an output folder. So far, I haven't had any success. I've played around with the "Attachment" transform as well as copying and pasting the example from the documentation for the IMAP transport. I'm not sure if that example is out of date or what, but I keep getting an error.
Here is the code from the "Configuration Example" in the IMAP docs:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.6/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.6/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.6/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.6/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.6/mule-vm.xsd">
<imap:connector name="imapConnector" />
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*" optional="false"/> ❶
</expression-transformer>
<file:connector name="fileName">
<file:expression-filename-parser/>
</file:connector>
<flow name="incoming-orders">
<imap:inbound-endpoint user="bob" password="password" host="emailHost"
port="143" transformer-refs="returnAttachments" disableTransportTransformer="true"/> ❷
<collection-splitter/>
<file:outbound-endpoint path="./received" outputPattern="#[function:datestamp].dat"> ❹
<expression-transformer>
<return-argument expression="payload.inputStream" evaluator="groovy" /> ❺
</expression-transformer>
</file:outbound-endpoint>
</flow>
</mule>
And here is the error I get (after changing all the connection details):
Element 'expression-transformer' cannot have character [children], because the type's content type is element-only.
Relevant info:
Mule ESB and Integration Platform
Version: 3.6.0 Build: ed775fdb
JDK: 1.8.0_31 (mixed mode)
OS: Windows 8.1 - (6.3, amd64)
Host: computername (192.168.1.116)
Full output: http://pastebin.com/1EAEbTFw
I could only get that error using the exact config you provided, because there are weird characters in it, see: ❶
I guess you copy-pasted from the docs site? Those are references within the docs.
Removed them and it should work.
Hi I am working with Mule Anypoint Studio and I am trying to implement a list of IP's but my program is allowing every request from all IP's and it works only for one request per browser. How it is working i have no Idea. Please elaborate the working . Please don't share Mule Documentation Link because there they have not given much information.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:filters="http://www.mulesoft.org/schema/mule/filters" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
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/filters http://www.mulesoft.org/schema/mule/filters/current/mule-filters.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<filters:config name="Filters" doc:name="Filters"/>
<flow name="mule-security-ipFlow1" doc:name="mule-security-ipFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="196.111.1.1" port="8081" doc:name="HTTP" path="ip"/>
<filters:filter-by-ip config-ref="Filters" regex="196.16.4.1,196.17.7.13" doc:name="Filters"/>
<set-payload value="#['Data Mast']" doc:name="Set Payload"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
there are two scenarios here, we can specify regular expression to allow certain ip range requests or we can specify single ip address as part regex attaribute value.
<filters:filter-by-ip config-ref="Filters" regex="${fms.iprange}"
doc:name="verify-ip-address" />
if we want to allow comma separated ip address, its better to write custom filter and do the required logic .
Depending on how you are intending to deploy your flow your other option is to use api-kit to apply the IP whitelist (or blacklist) to your flow as a policy: