5

I need to write a deployer extension where my requirement is to get the publish transaction id.

I tried with the following way:

public static String getTransactionId()
{
    ContentDeliveryKernel contentDeliveryKernel = null;
    try {
        contentDeliveryKernel = KernelFactory.getInstance().getKernel();
        TransactionManager tm = contentDeliveryKernel.getComponent(TransactionManager.class);
        Map<String, Long> activeTrans = tm.getActiveTransactions();
        if(activeTrans != null && !activeTrans.isEmpty())
        {
            Object keys[] = activeTrans.keySet().toArray();
            String rawTransId = (String)keys[0];
            return cleanupPackageId(rawTransId);
        }
    } catch (TridionLifecycleException ex) {
        return null;
    }

    return null;
}

But I am getting a stack overflow error after deployment on following line: contentDeliveryKernel = KernelFactory.getInstance().getKernel();

If anybody knows a better way to get a published transaction id then it would be helpful.

I am using sites 9.1.

2
  • Following is the stack trace: Oct 25 at 7:33
  • Is it a deployer extension or storage extension?
    – Velmurugan
    Oct 26 at 7:12
4

It is pretty easy. You have the following page for deployer extension sample:

https://docs.rws.com/783502/695281/sdl-tridion-sites-9-1/creating-a-custom-module

Plus, the override methods in deployer extensions receive TransportPackage which has method getTransactionId()

    public void process(TransportPackage data) throws ProcessingException {
        try {
            ProcessorInstructions processorInstructions = data.getProcessorInstructions();
            TCMURI transactionID = data.getTransactionId();

        } catch (Exception exception) {
            LOGGER.error(exception.getMessage());
        } finally {
            LOGGER.debug("**PageUndeployer process end**");
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.