XmlBlaster Logo

REQUIREMENT

mime.plugin.publishfilter

XmlBlaster Logo


Type NEW
Priority HIGH
Status CLOSED
Topic XmlBlaster has a MIME based plugin interface to filter, check or manipulate published messages
Des
cription

XmlBlaster allows you to publish messages. Sometimes you may need to check messages before you accept them. Another use case could be that you want to manipulate message contents when they arrive at xmlBlaster.

These are use cases where you may want to write a little plugin, allowing to intercept messages when they are published to xmlBlaster. With such a plugin you are able to add some business logic natively to the otherwise generic xmlBlaster core.

Example how to use the publish MIME plugin

As a plugin coder, you have to implement two interfaces

  • I_Plugin: Which allows xmlBlaster to load the plugin
  • I_PublishFilter: Which forces you to implement the intercept() method
This is simple and straight forward (see requirement mime.plugin.publishfilter.howto).

Filter Features:

  • MIME based plugin selection
    The plugin you code has to supply MIME types which it can handle. Only messages of this mime type are directed to the plugin. The mime type "*" registers the plugin for all message MIME types.
  • The filter intercepts published messages
    When a client invokes publish() to send a message to xmlBlaster, the message calls the appropriate plugin when it arrives in the server.
    This happens before xmlBlaster checks if it needs to be sent to another cluster node and before xmlBlaster stores or processes it.
    Publish/Subscribe and PtP messages are equally checked.
    If the plugin is registered for all mime types with "*", internal messages are send to the filter as well, usually you should just ignore them (see example in PublishLenFilter).
  • Allowed actions with a message
    You may do following actions with the new message:
    1. Accept the message
      Return values null, "" or "OK" accept the message
    2. Reject the message
      All other returned strings will reject the message and send the given string back to the publisher. For example a return value like "REJECTED" will be delivered as "<qos><state id='REJECTED'/></qos>" to the publisher, which is the return value of the publish() invocation.
    3. Modify the message
      The plugin may manipulate the content of the message if desired, delivering changed content to xmlBlaster. Changing of the key or qos is not allowed, as the problems which may ocure are not analyzed yet.
  • Multiple filters per mime type
    Multiple filter plugins can be specified for each published message. They are sequentially executed and if one filter rejects (the intercept() method returns no "" or "OK") the message is not accepted. The filters are logically AND connected.
  • Filter in cluster environment
    The filter is applied before the message is forwarded from a slave node to its master node. So you can suppress cluster messages in the slave already.

Example
XML

This is an example message for a publish() method invocation:

<key oid='LongMessage'/>
content="veeerrrrrylongcooontenttttttt"
<qos/>
      

As the message is too long for our plugin, the plugin.intercept() method returns "TOOLONG". xmlBlaster rejects the messages and returns for this publish()

<qos><state id='TOOLONG'/><qos>
      

If you return strings contain '<' characters, please embrace your return value with a <![CDATA[ ... ]]> section.

Example
any

Here are some typical use cases why to write a plugin:

  • A publish plugin could for example eliminate identical messages.
    Imagine that multiple radar stations track the same air plane. You could use the plugin to filter them and only pass one radar position of the same air plane further.
  • Another use case could be to reject messages which are to big, or you could write a regex plugin and reject messages with unwanted content.
  • Use the plugin for mime conversion (1).
    Imagine you receive documents in different formats like Staroffice, Winword etc.
    You could write a little plugin for those mime types and convert all messages to PDF or into some XML esperanto format.
  • Use the plugin for mime conversion (2).
    Imagine you receive air pressure values in different units like HPascal, Newton/sqare-millimeter, mbar, mm of mercury.
    You could write a little plugin for those mime types and convert all messages to standardized HPascal.
Configure

For coding and configuration of plugins please read the requirement mime.plugin.publishfilter.howto (see link below)

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

See API org.xmlBlaster.engine.mime.I_PublishFilter
See API org.xmlBlaster.engine.mime.demo.PublishLenChecker
See API org.xmlBlaster.util.plugin.I_Plugin
See REQ mime.plugin.publishfilter.howto
See REQ util.property.env
See REQ mime.plugin.accessfilter
See TEST org.xmlBlaster.test.mime.TestPublishFilter

This page is generated from the requirement XML file xmlBlaster/doc/requirements/mime.plugin.publishfilter.xml

Back to overview