Skip to content

Publishes Alfresco node events (create, update, delete) to an Apache Kafka topic.

Notifications You must be signed in to change notification settings

jecicorp/alfresco-kafka

 
 

Repository files navigation

Alfresco Kafka Integration

This is an Alfresco repository tier AMP that will publish events to an Apache Kafka topic when nodes are created, updated, or deleted. Events are also produced for permission changes, including when inheritance is enabled and disabled.

Events are generated using an Alfresco behavior that is bound to various class policies such as: onCreateNode, onUpdateProperties, and beforeDeleteNode.

Build

This project uses the Alfresco Maven SDK to build. The output is an AMP that can be installed into your Alfresco WAR using the Alfresco Module Management Tool (MMT).

Configure

There are two configurable settings:

  • Topic: Set the topic that the events should be published to. (Default: alfresco-node-events)
  • Bootstrap Servers: Set the Kafka servers to publish to. (Default: kafka:9092). Here 'kafka' is the name of service.

Both of these settings can be configured by setting the following in alfresco-global.properties:

kafka.topic=alfresco-node-events
kafka.server=kafka:9092

See docker-compose.yml file for details.

Example

This section includes an example of the event JSON. The events are all the same format with the exception of the event type, which can be one of:

  • CREATE
  • UPDATE
  • DELETE
  • PING
  • GRANT
  • REVOKE
  • ENABLE_INHERIT
  • DISABLE_INHERIT

Here is what an event looks like:

{
    "nodeRef": "70c60aea-d390-4fc7-b836-210c2778035d",
    "eventType": "CREATE",
    "path": "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/site/1.0}sites/{http://www.alfresco.org/model/content/1.0}jtp-test-site-1/{http://www.alfresco.org/model/content/1.0}documentLibrary/{http://www.alfresco.org/model/content/1.0}test2.txt",
    "created": 1567086666248,
    "modified": 1567086666248,
    "creator": "admin",
    "modifier": "admin",
    "mimetype": "text/plain",
    "contentType": "content",
    "siteId": "jtp-test-site-1",
    "size": 4,
    "parent": "244a089b-17ad-4a49-81f4-c8b17b7322a6",
    "permissions": {
        "permissions": [
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteConsumer",
                "authorityType": "GROUP",
                "permission": "SiteConsumer",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteCollaborator",
                "authorityType": "GROUP",
                "permission": "SiteCollaborator",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteContributor",
                "authorityType": "GROUP",
                "permission": "SiteContributor",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteManager",
                "authorityType": "GROUP",
                "permission": "SiteManager",
                "inherited": true
            }
        ],
        "inheritanceEnabled": true
    }
}

For folders, the size and mimetype are null and are not included in the JSON.

{
    "nodeRef": "8d8396a1-b9f8-444d-b9ea-f3a1e6971285",
    "eventType": "UPDATE",
    "path": "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/site/1.0}sites/{http://www.alfresco.org/model/content/1.0}jtp-test-site-1/{http://www.alfresco.org/model/content/1.0}documentLibrary/{http://www.alfresco.org/model/content/1.0}testfolder4",
    "created": 1567086551982,
    "modified": 1567088364629,
    "creator": "admin",
    "modifier": "admin",
    "contentType": "folder",
    "siteId": "jtp-test-site-1",
    "parent": "244a089b-17ad-4a49-81f4-c8b17b7322a6",
    "permissions": {
        "permissions": [
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteConsumer",
                "authorityType": "GROUP",
                "permission": "SiteConsumer",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteContributor",
                "authorityType": "GROUP",
                "permission": "SiteContributor",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteCollaborator",
                "authorityType": "GROUP",
                "permission": "SiteCollaborator",
                "inherited": true
            },
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteManager",
                "authorityType": "GROUP",
                "permission": "SiteManager",
                "inherited": true
            }
        ],
        "inheritanceEnabled": true
    },
    "tags": [
        "test1",
        "test2",
        "test3"
    ]
}

Permissions-related events are smaller. For GRANT, REVOKE, ENABLE_INHERIT, and DISABLE_INHERIT, the event contains only the node reference and the current access control list:

{
    "nodeRef": "953e16c4-d1f7-421e-bbe1-4f1123429c2a",
    "eventType": "DISABLE_INHERIT",
    "permissions": {
        "permissions": [
            {
                "authority": "GROUP_site_jtp-test-site-1_SiteManager",
                "authorityType": "GROUP",
                "permission": "SiteManager",
                "inherited": false
            },
            {
                "authority": "tuser1",
                "authorityType": "USER",
                "permission": "SiteContributor",
                "inherited": false
            },
            {
                "authority": "tuser3",
                "authorityType": "USER",
                "permission": "SiteContributor",
                "inherited": false
            }
        ],
        "inheritanceEnabled": false
    }
}

In the example above, inheritance was turned off for a folder, which left the object with only locally-set permissions.

Running via docker

1- Launch containers using ./run.sh build_start or ./run.bat build_start and verify that it

  • Runs Alfresco Content Service (ACS)
  • (Optional) Runs Alfresco Share
  • Runs Alfresco Search Service (ASS)
  • Runs PostgreSQL database
  • Deploys the JAR assembled module
  • Runs Zookeeper
  • Runs Kafka

Additionally, you can use docker ps command to checked whether all containers are up and running correctly.

2- If you want to watch the messages as they are sent to Kafka, then from $KAFKA_HOME, run:

`bin/kafka-console-consumer.sh --bootstrap-server localhost:9093 --topic alfresco-node-events --from-beginning`

For windows:

`bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9093 --topic alfresco-node-events --from-beginning`

Consuming Events

For an example showing how to consume these events from a Spring Boot app, see this project on GitHub.

About

Publishes Alfresco node events (create, update, delete) to an Apache Kafka topic.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 80.3%
  • Shell 8.1%
  • Batchfile 5.4%
  • JavaScript 3.4%
  • Dockerfile 2.7%
  • FreeMarker 0.1%