public void emitEvent ( final NamespaceSynchronizationConfig nsConfig , final ChangeEvent < BsonDocument > event ) { listenersLock . lock ( ) ; try { if ( nsConfig . getNamespaceListenerConfig ( ) == null ) { return ; } final NamespaceListenerConfig namespaceListener = nsConfig . getNamespaceListenerConfig ( ) ; eventDispatcher . dispatch ( ( ) -> { try { if ( namespaceListener . getEventListener ( ) != null ) { namespaceListener . getEventListener ( ) . onEvent ( BsonUtils . getDocumentId ( event . getDocumentKey ( ) ) , ChangeEvents . transformChangeEventForUser ( event , namespaceListener . getDocumentCodec ( ) ) ) ; } } catch ( final Exception ex ) { logger . error ( String . format ( Locale . US , "emitEvent ns=%s documentId=%s emit exception: %s" , event . getNamespace ( ) , BsonUtils . getDocumentId ( event . getDocumentKey ( ) ) , ex ) , ex ) ; } return null ; } ) ; } finally { listenersLock . unlock ( ) ; } }
Emits a change event for the given document id .