Exam4Training

What is a key difference between synchronous and asynchronous logging from Mule applications?

What is a key difference between synchronous and asynchronous logging from Mule applications?
A . Synchronous logging writes log messages in a single logging thread but does not block the Mule event being processed by the next event processor
B . Asynchronous logging can improve Mule event processing throughput while also reducing the processing time for each Mule event
C . Asynchronous logging produces more reliable audit trails with more accurate timestamps
D . Synchronous logging within an ongoing transaction writes log messages in the same thread that processes the current Mule event

Answer: B

Explanation:

Types of logging:

A) Synchronous: The execution of thread that is processing messages is interrupted to wait for the log message to be fully handled before it can continue.

● The execution of the thread that is processing your message is interrupted to wait for the log message to be fully output before it can continue

● Performance degrades because of synchronous logging

● Used when the log is used as an audit trail or when logging ERROR/CRITICAL messages

● If the logger fails to write to disk, the exception would raise on the same thread that’s currently processing the Mule event. If logging is critical for you, then you can rollback the transaction.

B) Asynchronous:

● The logging operation occurs in a separate thread, so the actual processing of your message won’t be delayed to wait for the logging to complete

● Substantial improvement in throughput and latency of message processing

● Mule runtime engine (Mule) 4 uses Log4j 2 asynchronous logging by default

● The disadvantage of asynchronous logging is error handling.

● If the logger fails to write to disk, the thread doing the processing won’t be aware of any issues writing to the disk, so you won’t be able to rollback anything. Because the actual writing of the log gets differed, there’s a chance that log messages might never make it to disk and get lost, if Mule were to crash before the buffers are flushed.

So Correct answer is: Asynchronous logging can improve Mule event processing throughput while also reducing the processing time for each Mule event

Exit mobile version