You can optionally create gateway sender and/or gateway receiver filters to control which events are queued and distributed to a remote site, or to modify the data stream that is transmitted between GemFire sites.
GemFire makes a synchronous call to the filter's beforeEnqueue method before it places a region event in the gateway sender queue. The filter returns a boolean value that specifies whether the event should be added to the queue.
GemFire asynchronously calls the filter's beforeTransmit method to determine whether the gateway sender dispatcher thread should distribute the event to a remote gateway receiver.
For events that are distributed to another site, GemFire calls the listener's afterAcknowledgement method to indicate that is has received an ack from the remote site after the event was received.
When a gateway sender processes a batch of events for distribution, GemFire delivers the stream to the getInputStream method of a configured GatewayTransportFilter implementation. The filter processes and returns the stream, which is then transmitted to the gateway receiver. When the gateway receiver receives the batch, GemFire calls the getOutputStream method of a configured filter, which again processes and returns the stream so that the events can be applied in the local cluster.
<cache>
<gateway-sender id="remoteA" parallel="true" remote-distributed-system-id="1">
<gateway-event-filter>
<class-name>com.gemstone.gemfire.util.SampleEventFilter</class-name>
<parameter name="param1">
<string>"value1"</string>
</parameter>
</gateway-event-filter>
<gateway-transport-filter>
<class-name>com.gemstone.gemfire.util.SampleTransportFilter</class-name>
<parameter name="param1">
<string>"value1"</string>
</parameter>
</gateway-transport-filter>
</gateway-sender>
</cache>
<cache>
...
<gateway-receiver start-port="1530" end-port="1551">
<gateway-transport-filter>
<class-name>com.gemstone.gemfire.util.SampleTransportFilter</class-name>
<parameter name="param1">
<string>"value1"</string>
</parameter>
</gateway-transport-filter>
</gateway-receiver>
</cache>
Cache cache = new CacheFactory().create();
GatewayEventFilter efilter = new SampleEventFilter();
GatewayTransportFilter tfilter = new SampleTransportFilter();
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setParallel(true);
gateway.addGatewayEventFilter(efilter);
gateway.addTransportFilter(tfilter);
GatewaySender sender = gateway.create("remoteA", "1");
sender.start();
Cache cache = new CacheFactory().create(); GatewayTransportFilter tfilter = new SampleTransportFilter(); GatewayReceiverFactory gateway = cache.createGatewayReceiverFactory(); gateway.setStartPort(1530); gateway.setEndPort(1551); gateway.addTransportFilter(tfilter); GatewayReceiver receiver = gateway.create(); receiver.start();