This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
||
Skip to end of metadata
Go to start of metadata

Introduction

This sample demonstrates how you can use the SynapseObserver interface to monitor the Synapse configuration at runtime.

Prerequisites

For a list of prerequisites, see Prerequisites to Start the ESB Samples.

Building the sample

  • To define the simple logging Synapse observer, open the <ESB_HOME>/repository/conf/synapse.properties file and add the following line:
    synapse.observers=samples.userguide.SimpleLoggingObserver
  • To set the log level of the samples.userguide package to INFO , open the  <ESB_HOME>/repository/conf/log4j.properties  file and add the following line:
    log4j.category.samples.userguide=INFO

Executing the sample

Start the ESB with any sample configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.

Analyzing the output

You will see that the SimpleLoggingObserver captures events that occur while constructing the Synapse configuration and logs them on the console as follows:

  2009-08-06 14:30:24,578 [-] [main]  INFO SimpleLoggingObserver Simple logging observer initialized...Capturing Synapse events...
  2009-08-06 14:30:24,604 [-] [main]  INFO SimpleLoggingObserver Endpoint : a3 was added to the Synapse configuration successfully
  2009-08-06 14:30:24,605 [-] [main]  INFO SimpleLoggingObserver Endpoint : a2 was added to the Synapse configuration successfully
  2009-08-06 14:30:24,606 [-] [main]  INFO SimpleLoggingObserver Endpoint : null was added to the Synapse configuration successfully
  2009-08-06 14:30:24,611 [-] [main]  INFO SimpleLoggingObserver Local entry : a1 was added to the Synapse configuration successfully
  2009-08-06 14:30:24,649 [-] [main]  INFO SimpleLoggingObserver Proxy service : StockQuoteProxy2 was added to the Synapse configuration successfully
  2009-08-06 14:30:24,661 [-] [main]  INFO SimpleLoggingObserver Proxy service : StockQuoteProxy1 was added to the Synapse configuration successfully
  2009-08-06 14:30:24,664 [-] [main]  INFO SimpleLoggingObserver Sequence : main was added to the Synapse configuration successfully
  2009-08-06 14:30:24,701 [-] [main]  INFO SimpleLoggingObserver Sequence : fault was added to the Synapse configuration successfully

The SimpleLoggingObserver is implemented as follows:

 package samples.userguide;

 import org.apache.synapse.config.AbstractSynapseObserver;

 public class SimpleLoggingObserver extends AbstractSynapseObserver {

     public SimpleLoggingObserver() {
         super();
         log.info("Simple logging observer initialized...Capturing Synapse events...");
     }
 }

It does not override any of the event handler implementations in the AbstractSynapseObserver class. The AbstractSynapseObserver logs all the received events by default.

 

  • No labels