Mule ESB: How I can run flow(s) automatically - mule

How I can run flow(s) automatically
Anyone can tell me how flow(s) run automatically.
Basically I am trying to read data from csv file and wants to store it in database. I have created flow for it and run, it start the application as you can see below:
INFO 2013-11-26 11:31:47,401 [main] org.mule.module.launcher.MuleDeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'read_csv_file' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
After this point I have no idea what I need to do to execute this flow. From where I need to hit this flow. I am stuck here please help me

Mule Flows are triggered by an event. It can be an event generated from another flow or it can be an event on the inbound-endpoint.
From the post it can be understood that the flow needs to be triggered from outside the application. So better use an Inbound-Endpointat the start of the flow to trigger the flow.
For your case you can use an file:inbound-endpoint at the start of your flow.
<flow name="main_flow">
<file:inbound-endpoint path="/path/to/input/folder" doc:name="File"></file:inbound-endpoint>
......
......... Message processors ....
</flow>

Flows are automatically started, you don't need to "run" them.
Messages will be processed depending on the message sources you have in your flows, which are the ones triggering the flow execution.
I would suggest you to carefully read the documentation:
http://www.mulesoft.org/documentation/display/current/Mule+Application+Architecture

You can either use a File component that reads the file from the location you mention depending on the polling frequency. Or If you try to read your file using a java component or expression or Groovy script you can automatically trigger using flow by using a Quartz component at the beginning of the flow.

Related

Is there a way to wait for batch process to complete in Mule 4?

I have a mule flow that runs a batch job. What I have found is that the batch job will branch and my flow will continue on. I would like to wait till the On Complete gets hit and return those results. I found that in older version there was a scope of run-and-wait. I don't see an equivalent in Mule 4. Any suggestion would be much appreciated.
Batch runs asynchronously with respect to the flow. That was the same in Mule 3.
I guess you could send a message to a VM queue in the onComplete stage and wait for it to be received on the flow.

Multiple mule-flow instances

I have mule app with single mainFlow. Flow receives jms-message from MQ by quartz:inbound-endpoint, processes it and puts in another queue. Messages are independed. Is it possible to run multiple instances of my flow for concurrent message processing?
enter image description here
Yes. As long as your flow is neither transactional or two-way (request-response), you can set-up various asynchronous processing strategies.
You can add it either visually in the Studio in the flow's properties or by manually adding the attribute processingStrategy="...yourStrategy" to the flow's XML declaration.
For an in-depth guide to what everything means and does, see https://docs.mulesoft.com/mule-user-guide/v/3.8/flow-processing-strategies

Life Cycle of Mule Event

Hi i have started working with Mule Anypoint Studio and would like to know what are the different stages of a basic Mule Event. Like how does mule start and stop a particular event in a flow. Also how a flow gets initialised.
The mule event can not be compare as a "life cycle" bean as the behaviour is completely different.
A Mule Event is created when a message source is trigger by any action , this action outputs a message. The event contain this message inside.
When the event pass through a different number of processors, you just modify the data in that message.
If the transport you are using is based on request-response transport, the same event continues in the same thread.
Is it possible to create new events / copy the event into another one (scatter-gather), etc..
But there is nothing like lifecycle in a MuleEvent , event is created, processed and it ends when the process is completed.

Audit mule inbound outbound messages

we are trying to audit all incoming/outgoing messages, header information in our mule flow.
For same we have tried to use 'wire-tap' which we dint found so useful also its working on mule 3.6.1 but giving error in 3.7.
Any idea/suggestion for auditing?
Ok let me add some more details:
What we are trying to do is- Whatever message comes or flows via flow components we want to copy it in some sub flow (say in queue) without interrupting the main flow so that we can check the message.
you can make it work in several ways
1) Wire tap is one of the choice. You can route your messages asynchronously to sub flow and sub flow will do the auditing work. But I don't know why you didn't found wiretap useful. Can you explain in more.
2) All the messages your receive from the main flow, those you can post to JMS queue. So another flow will read from there and do the auditing work. Use of this multiple projects can use the same piece of code and post JMS queue for auditing.
This can be done in many different ways and you kind of mentioned them in your question such as logger component and interceptor.
All the headers are available as message properties so if you log the entire message they are shown. Simply put an logger component after the inbound endpoint and one before the outbound endpoint and this is easily done.
If you need some log entries transformation you could always put that in a wire tap so you don't interfere with the functionality of your flow.

how to know the time taken by each component in mule?

In my mule project i want to know the time taken by each component in a flow to execute and also the total time taken by a flow to execute.How can i know that.I tried by googling.i found timer interceptor as answer.
But how to configure it to know the datamapper execution time?And also i dont know how to configure it for a flow to know the flow execution time.
You can subscribe to message processor notifications and print the before and after timestamps. Take a look at: http://www.mulesoft.org/documentation/display/current/Mule+Server+Notifications