PrizmDoc v13.1 - Updated
Affinity Tokens & Cluster Mode
Administrator Guide > Cluster Server Environments > PrizmDoc Server > Affinity Tokens & Cluster Mode

Requests for Work Files, Markup Burners, Redaction Creators & Content Converters Require Affinity Tokens

In cluster mode only, requests for WorkFile, MarkupBurner, RedationCreator, and ContentConverter resources require an additional bit of data, called an affinity token, to ensure they are routed correctly by the Cloud Entry Point (CEP). The affinity token is a Base64 encoded string that contains encrypted information necessary to route related requests to the same PrizmDoc server. Getting related requests to the same server is critical as the necessary data is cached locally.

In cluster mode, the PrizmDoc Back-end RESTful Services will automatically generate an affinity token when it receives a POST request for a new ViewingSession, WorkFile, MarkupBurner, RedactionCreator or ContentConverter resource and return it in the response. Once you have obtained an affinity token, you will need to pass this in with related requests using the "Accusoft-Affinity-Token" HTTP custom header. In the case of a ViewingSession, the affinity token is only required when retrieving or setting the source document WorkFile ID for that session.

The following example request and response sequence demonstrates how an affinity token is used to burn markup into a document. Notice how all requests, (except the first request), use the same affinity token even for subsequent POST requests.

Example
Copy Code
// 1. Create first work file, the source PDF document to burn-in markup.
POST http://192.168.0.1:18681/PCCIS/V1/WorkFile?FileExtension=pdf
Content-Type: application/octet-stream
[binary data]
200 OK
Content-Type: application/json
{
    "fileId": "5qTYa3gzN9gYUb5SzqUhqg",
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 2. Create the second work file, the XML markup to burn-in.
//    Pass in the affinity token generated from the previous request so that this
//      XML data is stored on the same PCC server.
POST http://192.168.0.1:18681/PCCIS/V1/WorkFile?FileExtension=xml
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
Content-Type: application/xml
[xml data]
200 OK
Content-Type: application/json
{
    "fileId": " o1bLJwFGxf9QGuTkyrOqig",
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 3. Create the markup burner resource, again on the same PCC server where we created
//      the work files in the previous requests.
POST http://192.168.0.1:18681/PCCIS/V1/MarkupBurner
Content-Type: application/json
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
{
    "input": {
        "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
        "markupFileId": "o1bLJwFGxf9QGuTkyrOqig"
    }
}
200 OK
Content-Type: application/json
{
    "processId": "Rr64ma-U_HseoPrs6y0iiw",
    "expirationDateTime": "2014-12-03T18:30:49.460Z",
    "input": {
        "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
        "markupFileId": " o1bLJwFGxf9QGuTkyrOqig"
    },
    "state": "processing",
    "percentComplete": 0,
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 4. Get status of markup burning process until state is "complete".
GET http://192.168.0.1:18681/PCCIS/V1/MarkupBurner/Rr64ma-U_HseoPrs6y0iiw
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
200 OK
Content-Type: application/json
{
    "processId": "Rr64ma-U_HseoPrs6y0iiw",
    "expirationDateTime": "2014-12-03T18:30:49.460Z",
    "input": {
        "documentFileId": "5qTYa3gzN9gYUb5SzqUhqg",
        "markupFileId": " o1bLJwFGxf9QGuTkyrOqig"
    },
    "state": "complete",
    "percentComplete": 100,
    "output": {
        "documentFileId": "5ufb3ytUb1BxxgSUAk_G9Q"
    },
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 5. Get the burned document once the markup burning process is complete
GET http://192.168.0.1:18681/PCCIS/V1/WorkFile/5ufb3ytUb1BxxgSUAk_G9Q
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
200 OK
Content-Type: application/pdf
[binary data]

Likewise, the following request and response sequence demonstrates how an affinity token is used in a content conversion workflow:

Example
Copy Code
// 1. Create first work file, the source PDF document to be converted.
POST http://192.168.0.1:18681/PCCIS/V1/WorkFile?FileExtension=docx
Content-Type: application/octet-stream
[binary data]
200 OK
Content-Type: application/json
{
    "fileId": "5qTYa3gzN9gYUb5SzqUhqg",
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 2. Create the content converter process. Pass in the affinity token generated
//    from the previous request so that resource is stored on the same PCC server.
POST http://192.168.0.1:18681/v2/contentConverters
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
{
    "input": {
        "src": {
            "fileId": 5qTYa3gzN9gYUb5SzqUhqg
        },
        "dest": {
            "format": "pdf"
        }
    }
}
200 OK
Content-Type: application/json
{
    "input": {
        "src": {
            "fileId": 5qTYa3gzN9gYUb5SzqUhqg
        },
        "dest": {
            "format": "pdf" ",
            "pdfOptions: {
                "forceOneFilePerPage": false
            }
        }
    },
    "expirationDateTime": "2015-12-17T20:38:39.796Z",
    "processId": "E1kNzWtrUJp4rXI5YnLUgw",
    "state": "processing",
    "percentComplete": 0,
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 3. Get status of content conversion process until state is "complete".
GET http://192.168.0.1:18681/v2/contentConverters/E1kNzWtrUJp4rXI5YnLUgw
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
200 OK
Content-Type: application/json
{
    "input": {
        "src": {
            "fileId": 5qTYa3gzN9gYUb5SzqUhqg
        },
        "dest": {
            "format": "pdf",
            "pdfOptions: {
                "forceOneFilePerPage": false
            }
        }
    },
    "expirationDateTime": "2015-12-17T20:38:39.796Z",
    "processId": "E1kNzWtrUJp4rXI5YnLUgw",
    "state": "complete",
    "percentComplete": 100,
    "output": {
        "results": [
            {
                "fileId": "KOrSwaqsguevJ97BdmUbXi",
                "src": [{ "fileId": 5qTYa3gzN9gYUb5SzqUhqg, "pages": 1-3" }]
            }
        ]
    }
    "affinityToken": "rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w="
}
// 5. Get the converted document once the content conversion process is complete
GET http://192.168.0.1:18681/PCCIS/V1/WorkFile/KOrSwaqsguevJ97BdmUbXi
Accusoft-Affinity-Token: rcqmuB9pAa8+4V7fhO1SXzawy/YMQU1g8lLdNDe5l7w=
200 OK
Content-Type: application/pdf
[binary data]