To receive Atlas entity notifications a consumer should be obtained through the notification interface. Entity change notifications are sent every time a change is made to an entity. Operations that result in an entity change notification are:
ENTITY_CREATE
- Create a new entity.ENTITY_UPDATE
- Update an attribute of an existing entity.TRAIT_ADD
- Add a trait to an entity.TRAIT_DELETE
- Delete a trait from an entity.// Obtain provider through injection… Provider<NotificationInterface> provider; // Get the notification interface NotificationInterface notification = provider.get(); // Create consumers List<NotificationConsumer<EntityNotification>> consumers = notification.createConsumers(NotificationInterface.NotificationType.ENTITIES, 1);
The consumer exposes the Iterator interface that should be used to get the entity notifications as they are posted. The hasNext() method blocks until a notification is available.
while(consumer.hasNext()) { EntityNotification notification = consumer.next(); IReferenceableInstance entity = notification.getEntity(); … }