The PeerAssociationResource object - The PeerAssociationResource object - Alfresco - Alfresco Events SDK for Out-of-Process Events - Alfresco/Alfresco-Events-SDK-for-Out-of-Process-Events/6.3/Alfresco-Events-SDK-for-Out-of-Process-Events/Install/Event-API-Resource-objects/The-PeerAssociationResource-object - 6.3 - 6.3

Alfresco Events SDK for Out-of-Process Events

Platform
Alfresco
Product
Alfresco Events SDK for Out-of-Process Events
Release
6.3
License
ft:lastPublication
2025-09-04T22:27:16.404000
ft:locale
en-US

When working with the Event API and Peer-2-Peer associations there is one data object called PeerAssociationResource that is used over and over. It’s used to get to the JSON association data returned in the JMS message payload.

Here is an example payload for a Peer-2-Peer association created event (see the Peer association created event section in the Alfresco Content Services documentation):

{
  "specversion": "1.0",
  "type": "org.alfresco.event.assoc.peer.Created",
  "id": "8a8113a2-fa67-4914-9ecb-2ec47c456159",
  "source": "/08d9b620-48de-4247-8f33-360988d3b19b",
  "time": "2021-01-28T13:42:34.352956Z",
  "dataschema": "https://api.alfresco.com/schema/event/repo/v1/peerAssocCreated",
  "datacontenttype": "application/json",
  "data": {
    "eventGroupId": "78da21cc-fa5a-47d1-afcb-03005229efa9",
    "resource": {
      "@type": "PeerAssociationResource",
      "assocType": "fdk:reviews",
      "source": {
        "id": "a4eb7684-0ffe-4bf5-b6f7-4297a6e4ee84"
      },
      "target": {
        "id": "f826ac49-0262-48af-8f63-f87eb7007078"
      }
    }
  }
}

In an event handler, being it pure Java or Spring Integration based, we can get to the payload data via the org.alfresco.event.sdk.model.v1.model.PeerAssociationResource object:

public class Peer2PeerAssocCreatedEventHandler implements OnPeerAssocCreatedEventHandler {

    public void handleEvent(final RepoEvent<DataAttributes<Resource>> repoEvent) {
        PeerAssociationResource resource = (PeerAssociationResource) repoEvent.getData().getResource();
        LOGGER.info("A Peer-Peer association was created: Assoc Type {}: Source {} -> Target {}", resource.getAssocType(), 
                resource.getSource().getId(), resource.getTarget().getId());
    }
}

The resource.getSource().getId() call will return the Node ID for the source node in the association and the resource.getTarget().getId() call will return the Node ID for the target node.