Versions Compared

Key

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

In addition to the default publisher types, you can define your own custom publisher. This provides more flexibility to publish events that are sent to WSO2 products. Each event publisher implementation is an OSGI bundle. Therefore, you can easily deploy it as well as undo its deployment on a WSO2 product. To create a custom event publisher, import the org.wso2.carbon.event.output.adaptor.core package that contains the skeleton classes/interfaces required for the custom publisher implementation.

...

  • void init() throws OutputEventAdapterException

    This method is called when initiating the event publisher bundle. Relevant code segments that are needed when loading OSGI bundle can be included in this method.

  •       void testConnect() throws TestConnectionNotSupportedException, ConnectionUnavailableException

    This method is used to test the connection of the publishing server.

  • void connect() throws ConnectionUnavailableException

    This method can be called to connect to the backend before the events are published.

  • void publish(Object message, Map<String, String> dynamicProperties) throws ConnectionUnavailableException

    This method publishes events. It throws the ConnectionUnavailableException if it cannot connect to the backend.

  • void disconnect()   

    This method is called after the publishing is done, or when the ConnectionUnavailableException is thrown.

  • void destroy()

    This method can be used to clean all the resources consumed.

  • boolean isPolled()

    This method checks whether events get accumulated at the adapter, and clients connect to it to collect events.

The following is a sample Email publisher implementation of the methods described above.

...