Log request event during debug in Mule 4 - anypoint-studio

I want to log an outbound request event (whether it be to http, smb or lambda) before sending it, in debug mode in Anypoint Studio. Is that possible? If yes, how to do it?

For the Mule HTTP connector, and other connectors that use the Mule HTTP service, you can enable HTTP wire logging as you mentioned in your answer, by configuring a log4j2 logger in the log4j2.xml file of the application, or in the logging tab in Runtime Manager. Each Mule version has a specific logger. Please take a look at the KB article How to Enable HTTP Wire Logging for detailed instructions.
Specifically for Mule 4.x applications:
<Loggers>
...
<AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG" />
...
</Loggers>
For other connectors you will need to check the documentation of said connectors. I'm not sure if you actually intend to debug the protocol of each connector (for example SMB requests) or just want to see if the connector is doing anything. If the former, most connector doesn't provide the same level of protocol detail as the HTTP connector. You might find it more useful to do a traffic capture and use a packet analyzer like Wireshark for that. For the later, it will depend on each connector what they can print with a logger. This KB article provides instructions for some other connectors.

Adding async logger declaration in log4j2.xml can help in this condition.
For example, I used
<Loggers>
...
<AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG" />
...
</Loggers>
and it helped me for Http and aws-lambda connectors.

Related

connecting mule ESB to Apache web server

How to access the data packets routed to apache webserver in Mule ESB flow.
After I call the exposed webservice, the webservice sends two responses,
To mule server
Routes response XML as data packets to apache webserver.
Can someone help in how to proceed with second flow? Thanks.
Use a Java library that understands PCAP and create your own Mule connector around it.
Reference:
List of Java PCAP libraries: https://en.wikipedia.org/wiki/Pcap#Wrapper_libraries_for_libpcap.2FWinPcap
Mule connector development kit: https://developer.mulesoft.com/docs/display/current/Anypoint+Connector+DevKit

Some concept questions on Mulesoft

I have some questions on concepts of Mulesoft. If you could answer that would be appreciated.
1.When mule connects to an FTP server and checks for new files,does Mule by default deletes the file once it is downloaded? And can FTP is available both as polling and as event subscription based?
When we connect to a RESTful service over HTTP, can Dynamic endpoints select whether HTTP or HTTPS is used or can be used to set the Host, Port and Path? (multiple choice for this question: a. Dynamic endpoints can select what transport to use. b. The Host, Port and Path can be set using dynamic endpoint. c. Dynamic endpoint can select whether HTTP or HTTPS is used. Which one is correct?)
in configuration, if
is used, does it mean my1.properties will take precedence?
Thanks!
1a) Community FTP connector will always delete the remote file. Enterprise FTP connector allows you to move it to another folder.
1b) Reading FTP connector is only available as a polling mechanism to read files from a FTP server.
2) The only part that can not be dynamic is the scheme, but you could place two connectors (one for HTTP and another for HTTPS) inside a choice and select which one to use dynamically.
3) I didn't get this, please elaborate a bit more.
HTH,
Marcos
Yes, it does. Mule EE give more features as you can see in the documentation FTP is always polling the directory.
You can setup HTTP or HTTPS. But, you can use a composite-source and tell that your flow is available for HTTP and HTTPS.
I know that it is possible, I found time ago the same requirement for FTP in mule forum. Hope this help
<!-- streaming to prevent deleting remote file -->
<ftp:connector name="ftpConnector" streaming="true" />
<flow name="ftpBridge">
<vm:inbound-endpoint path="fetchFtpFile" exchange-pattern="request-response"/>
<scripting:component>
<scripting:script engine="groovy">
def ftpFileUri = "ftp://${payload.userName}:${payload.password}#${payload.host}${payload.path}?fileNameFilter=${payload.fileName}"
muleContext.client.request(ftpFileUri, 30000L);
</scripting:script>
</scripting:component>
</flow>
If you want to load properties you can use spring to do that. Review this link.

How can I test a flow with ActiveMq in local

I'm started to work with Mule and Mule Studio (version 3.5): my goal is rewriting some flows that now is workign, but with a bad syntax.
In this moment I have a flow with some JMS connector and JMS endpoint for acquiring data (my flows are using ActiveMQ 5.10): the configuration XML file is ok and I want to test this flow, but I have'nt a big experience in JMS and system integration.
I think to create a JMS producer and, into run,
start up Mule (with all his flows, endpoints, etc, JMS queues);
start the JMS producer: in run the producer
links to name queue defined in configuration Mule
create a message
send this message to Mule
And the test asserts the
Mule receive the message by the producer
Mule don't loss the message
Mule turn this message to correct flow and relative elaboration
My problem is the lack of manuality and pratical work-ability to link Mule and producer: I tried to use http://activemq.apache.org/hello-world.html but the code is useless for me because it work correctly without Mule, but in my case the tests has to fail if Mule is stopped.
Has everybody any suggest, please?
Just set up an activemq connector without addresss, that will use the default address of vm://localhost that instructs the connector and activemq to act as a local embedded server.
<jms:activemq-connector name="JmsConnector" specification="1.1" />

Mule ESB and Throttling

IN the following link:
http://www.mulesoft.org/documentation/display/current/Mule+ESB+3.4.0+Release+Notes
I see the following
EE-3141 When using a Throttling policy with throttling statics enabled, limit headers are swapped.
However, I can find no example of throttling policies within Mule ESB, but there is possibly a throttling policy within the Anypoint API Manager
Could someone please provide a link to how to use a Throttling policy within Mule ESB?
Thanks
To achieve correct Throttling behaviour you can follow below steps:
Configure a queue (for example, a persistent VM or a JMS queue to avoid message lost during the Mule server crash) after your inbound endpoint.
Configure scheduled delay, for example AMQ_SCHEDULED_DELAY in case of ActiveMQ, to a desired value. If the queue does not support scheduled delay, then we need to find our way to achieve the delay, probably using a Java component.
Finally, configure the outbound endpoint.
The Throttling module (which can be configured as throttler or rate limiter) comes out of the box with any Mule API Gateway distribution. Mule EE comes with a light weight version of it. If you are using Anypoint API Platform, then you don't need to pay attention to the internals of how it is being done: Simply apply/unapply the policy to your managed API and it will work like a charm.
Even i tried implementing the Throttling concept in mule flows. There is no exact way of implementation for this , but i was able get that nature into the flows using the receiver thread profiling at inbounds and dispatch threading profiles on outbound connectors.

Create mbean in Mule - monitored by Mule Management Console

We need to monitor HornetQ messaging (part of Jboss) - monitoring is in terms of message arrival in queue, number of messages, messages consumed, auditing message payload. Does HornetQ expose JMX Mbean to monitor this process?
As part of integration strategy this information has to be displayed on Mule Management Console. Mule Management Console can probe only mule instances mbeans. To overcome this we probably need to write custom mbean in Mule which connect to HornetQ messaging, same can be probably displayed on MMC. How do we write custom JMX Mbean on mule and this needs to deployed on to mbean server (agent) and scheduled?
Thanks
Personally I have never tried this before, but it should be possible to instruct HornetQ using an MBeanServer bean to use Mule's JMX server.