|
xmlBlaster 2.1.0 contributions API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xmlBlaster.contrib.mime.DropIfNotDeliverableUniqueOnly
public class DropIfNotDeliverableUniqueOnly
Sometimes we need to support this subscribe pattern: A client only wants the newest message with this details:
- Initial connect and subscribe: send current newest (or given history depth) - If it is online it is a normal subscription - If it is offline don't add messages to callback queue - If it comes online again check if current message was delivered, if not send it initially (if redeliverNewestOnReconnect==false which is default; else on reconnect the newest is always send. Note: You can't use both variants simultaneously as it operates on the session Map)
If a client callback goes to polling, this plugin removes all existing subscriptions.
The client needs to add a filter Qos to its SubscribeQos to activate the plugin.
and needs to re-subscribe on relogin if desired.
The message uniqueness is checked per topic, but if you pass a client property "_uniqueGroupId" this is used to check uniqueness: Messages with the same "_uniqueGroupId" value are compared to decide if delivered already. This is like a sub-group of the topic and is for your convenience only as it could be solved by having a separate topic for each "_uniqueGroupId".
This makes only sense if the client is operating in fail save mode (-dispatch/callback/retries -1) and reconnects with the same publicSessionId > 0 (-session.name jack/session/1) so that its session is found again.
Configuration example (put to xmlBlaster.properties):
MimeAccessPlugin[DropIfNotDeliverableUniqueOnly][1.0]=\ org.xmlBlaster.contrib.mime.DropIfNotDeliverableUniqueOnly,dropper.types=*,uniqueGroupIdKeyName=_myuniqueGroupIddropper.types=* is default and activates the plugin for any published message where a subscriber has set this filter,
<qos>
<multiSubscribe>false</multiSubscribe>
<local>false</local>
<initialUpdate>false</initialUpdate>
<updateOneway>false</updateOneway>
<notify>false</notify>
<persistent>false</persistent>
<filter type='DropIfNotDeliverableUniqueOnly'>
<![CDATA[_]]>
</filter>
</qos>
The query statement '_' is ignored by this plugin.
This plugin is a singleton and loaded once only for multiple subscribers configuring it
Example to try on command line
export CLASSPATH=$XMLBLASTER_HOME/lib/xmlBlaster.jar
Start the server:
java org.xmlBlaster.Main
Start a sniffer GUI to see what happens:
cd ~/xmlBlaster
build SimpleReader
Start the subscriber which wants the newest and unique message only:
java javaclients.HelloWorldSubscribe -session.name subscriber/session/1 -disconnect false -multiSubscribe false -initialUpdate true -unSubscribe false -dispatch/callback/retries -1 -filter.type DropIfNotDeliverableUniqueOnly -filter.query _
(Avoid disconnect as it cleans up the session)
(example to get first ten of history: -historyNumUpdates 10 -historyNewestFirst false)
Start the publisher for two groupIds:
java javaclients.HelloWorldPublish -clientProperty[_uniqueGroupId] weather.south
| Field Summary | |
|---|---|
static java.lang.String |
MIME_TYPES
|
| Constructor Summary | |
|---|---|
DropIfNotDeliverableUniqueOnly()
|
|
| Method Summary | |
|---|---|
java.lang.String[] |
getMimeExtended()
Get the content MIME version number for which this plugin applies |
java.lang.String[] |
getMimeTypes()
Get the content MIME type for which this plugin applies, currently { "*" }. |
java.lang.String |
getName()
Get a human readable name of this filter implementation |
java.lang.String |
getType()
Return plugin type for Plugin loader |
java.lang.String |
getVersion()
Return plugin version for Plugin loader |
void |
init(org.xmlBlaster.util.Global glob,
org.xmlBlaster.util.plugin.PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin). |
void |
initialize(org.xmlBlaster.engine.ServerScope serverScope)
This is called after instantiation of the plugin |
boolean |
match(org.xmlBlaster.authentication.SessionInfo receiver,
org.xmlBlaster.util.MsgUnit msgUnit,
org.xmlBlaster.engine.mime.Query query)
Check if the filter rule matches for this message. |
void |
shutdown()
Cleans up the resource. |
void |
toAlive(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
|
void |
toAliveSync(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
|
void |
toDead(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState,
org.xmlBlaster.util.XmlBlasterException xmlBlasterException)
|
void |
toPolling(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String MIME_TYPES
| Constructor Detail |
|---|
public DropIfNotDeliverableUniqueOnly()
| Method Detail |
|---|
public void initialize(org.xmlBlaster.engine.ServerScope serverScope)
initialize in interface org.xmlBlaster.engine.mime.I_AccessFilterglob - The Global handle of this xmlBlaster server instance.
public void init(org.xmlBlaster.util.Global glob,
org.xmlBlaster.util.plugin.PluginInfo pluginInfo)
throws org.xmlBlaster.util.XmlBlasterException
init in interface org.xmlBlaster.util.plugin.I_Pluginorg.xmlBlaster.util.XmlBlasterExceptionI_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)public java.lang.String getType()
getType in interface org.xmlBlaster.util.plugin.I_Pluginpublic java.lang.String getVersion()
getVersion in interface org.xmlBlaster.util.plugin.I_Pluginpublic java.lang.String getName()
getName in interface org.xmlBlaster.engine.mime.I_AccessFilterpublic java.lang.String[] getMimeTypes()
getMimeTypes in interface org.xmlBlaster.engine.mime.I_AccessFilterpublic java.lang.String[] getMimeExtended()
getMimeExtended in interface org.xmlBlaster.engine.mime.I_AccessFilter
public boolean match(org.xmlBlaster.authentication.SessionInfo receiver,
org.xmlBlaster.util.MsgUnit msgUnit,
org.xmlBlaster.engine.mime.Query query)
throws org.xmlBlaster.util.XmlBlasterException
org.xmlBlaster.engine.mime.I_AccessFilterNote that you are not allowed to manipulate the content or XmlKey or QoS of a message with your plugin as this would affect all other subscribers (you are working on a reference to the original message). You can find out the publisher name like msgUnit.getQosData().getSender()
match in interface org.xmlBlaster.engine.mime.I_AccessFilterreceiver - The session object describing the receiver, is never null.msgUnit - The message to check, is never null.query - The query containing the filter rule on subscribe/get usually
the client defines his own rule which is passed here.org.xmlBlaster.util.XmlBlasterException - Is thrown on problems, for example if the MIME type
does not fit to message content.public void shutdown()
org.xmlBlaster.util.plugin.I_Plugin
shutdown in interface org.xmlBlaster.engine.mime.I_AccessFiltershutdown in interface org.xmlBlaster.util.plugin.I_Plugin
public void toAlive(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
toAlive in interface org.xmlBlaster.util.dispatch.I_ConnectionStatusListener
public void toAliveSync(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
toAliveSync in interface org.xmlBlaster.util.dispatch.I_ConnectionStatusListener
public void toDead(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState,
org.xmlBlaster.util.XmlBlasterException xmlBlasterException)
toDead in interface org.xmlBlaster.util.dispatch.I_ConnectionStatusListenerxmlBlasterException - Can be null
public void toPolling(org.xmlBlaster.util.dispatch.I_DispatchManager dispatchManager,
org.xmlBlaster.util.dispatch.ConnectionStateEnum oldState)
toPolling in interface org.xmlBlaster.util.dispatch.I_ConnectionStatusListener
|
xmlBlaster 2.1.0 contributions API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||