Skip to main content

Product: OpenFusion Notification Service

Version: ALL

 

Description:

What happens to a filter when the proxy it is attached to is destroyed?

 

Resolution:

All filters created from the filter factory are persistent objects within the service.

If a proxy is destroyed, any filters attached to that proxy will not be destroyed. It is the client's responsibility to manage filter lifetimes; if the client code has a reference to the filter, it can use this reference to re-use or destroy the filter. The easiest way to maintain a filter reference is via the filter's IOR, since this is a string and therefore easily stored (e.g. in a file or a database).

Example filter creation code, including obtaining the IOR, is as follows:

// Create the filter.
Filter filter = channel.default_filter_factory ().create_filter ("EXTENDED_TCL");
EventType types[] = new EventType[0];
ConstraintExp exp[] = new ConstraintExp[1];
exp[0] = new ConstraintExp (types, "$Priority > 6");
filter.add_constraints (exp);
// Attach it to the proxy.
...
// Store the filter IOR for reuse later on.
String filterIOR = orb.object_to_string (filter);

At a later point in the code, you can use the IOR to obtain a reference to the filter.

// Convert the IOR back into a filter instance.
org.omg.CORBA.Object cobj = orb.string_to_object (filterIOR);
Filter newFilterRef = FilterHelper.narrow (cobj);

If destroying a filter (rather than re-using it), you will need to make sure that the filter has been removed from all proxies/admins to which it was attached before you destroy it. Otherwise the proxy/admin will contain a reference to a destroyed filter, which will produce errors in the service log if events are still flowing in the time between the proxy's destruction and removal.


#OpenFusion
#KnowledgeDocs