Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

One of the main benefits of Fabric3 is it enables developers to write more manageable applications. This chapter covers how to expose components as part of the Management Resource Famework and as JMX MBeans.

...

It is also possible to defile custom channels to send events. This allows application events to be segregated. Below is an example of a configuring a channel. Note that the channel is set as synchronous, which means events will be dispatched to listeners synchronously. This ensures log events are recorded in order:
<composite
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:f3="urn:fabric3.org"...>
<channel name="CustomMonitorChannel"
requires="f3:synchronous"/>
</composite>
To attach a logger to the channel, use implementation.monitor:
<composite ...>
<component name="TestChannelMonitor">
<implementation.monitor/>
<consumer name="monitor" source="CustomMonitorChannel"/>
</component>
</composite>
XXXXXXXXXXXXX
Example of configuring a file-based appender:
<implementation.monitor>
<configuration>
<appender name="CUSTOM" class="ch.qos.logback.core.RollingFileAppender">
<file>application.log</file>
<encoder>
<pattern>[%level %thread %d{YY:MM:DD HH:mm:ss.SSS}] [%logger] %msg%n%ex</pattern>
</encoder>
</appender>
</configuration>
</implementation.monitor>
An event can be dispatched to a custom channel by specifying the channel name on the @Monitor annotation:
public class CalculatorImpl implements Calculator{
private CalculatorMonitor monitor;
public CalculatorImpl(@Monitor("CustomMonitorChannel" monitor){
this.monitor = monitor;
}
public double add(double n1, double n2) {
monitor.add(n1,n2);
return n1+n2;
}
//...
} (MRF) and as JMX MBeans.



Page Tree
rootFABRIC:@self