此内容没有您所选择的语言版本。
5.5. Custom Listeners for Remote Cache
Custom listeners for a remote cache can be registered in the same way as an embedded cache, with the exception that
sync=false
must be present. For instance:
Using only Java
from(infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener") .to(mock:result);
from(infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener")
.to(mock:result);
Using Blueprint and Java
Java class:
The instance of
myCustomListener
must exist. Users are encouraged to extend the org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener
class and annotate the resulting class with @ClientListener
; this annotation is found in org.infinispan.client.hotrod.annotation.
Remote listeners may also be associated with custom filters and converters as shown below:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@ClientListener(includeCurrentState=true, filterFactoryName = "static-filter-factory", converterFactoryName = "static-converter-factory") private static class MyCustomListener extends InfinispanRemoteCustomListener { }
@ClientListener(includeCurrentState=true, filterFactoryName = "static-filter-factory", converterFactoryName = "static-converter-factory")
private static class MyCustomListener extends InfinispanRemoteCustomListener {
}
In order to use custom filters or converters classes annotated with
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@NamedFactory
must be implemented. A skeleton that implements the necessary methods is shown below:
Custom filters and converters must be registered with the server. Registering these classes is documented in the
Remote Event Listeners
section of the Red Hat JBoss Data Grid Developer Guide.
Note
In order to listen for remote HotRod events the cacheManager must be of type
RemoteCacheManager
and instantiated.