8

We have a requirement where once the page is successfully published from Tridion on page post publish we need to make a httpwebrequest to our presentation/DD4T content delivery site to retrieve the complete html markup of the same page(which is published in the context) as webresponse . So that this markup contains all latest changes we made to content and we use this markup to store in custom DB along with other metadata of current page for search indexing purposes.

We tried using Event handler on page and subscribed to PublishEventArgs on TransactionCommitted phase but the code written in this functionality is executing before the publish transaction is completed/shown success in publish queue ( my expectation is the code in this event should trigger after page is successfully published to broker and transaction is committed but it’s not the case when implemented)

We also tried Deployer extension on post-transaction phase but even this part executes before transaction is committed i.e soon Tridion default deployment modules are executed.

So in both above approaches we are getting old content while we do httpwebrequest rather than latest published changes to broker DB. In case page is published for very first time we get obviously page not found error. Our goal is to get latest published content soon page is published and update search indexes. My thought of keeping our custom logic in Tridion modules is, so that I can get hold of current Page object which is being published and also use few page metadata info.

Just to be clear we are using DD4T on CD for our presentation site. So complete latest htmlmarkup of the page is available only after contents are committed to broker and after once we make a request to page. We are currently disabling DD4T cache on site.

Can anyone please suggest me in Tridion when exactly can I capture that the page is successfully published i.e. transaction is committed/CD server sends a success message back to CM server, so that I can invoke my custom code for querying delivery site for latest content? Any suggestions/help is highly appreciated.

  • Yet another example of confusing a requirement and a proposed technical approach. (Anyway - why would you think that the transaction scope referenced by TransactionCommitted on a Publish event would also include processing Deployment feedback?) So is your requirement to index newly published content? – Dominic Cronin Aug 7 '14 at 22:23
6

The event you attached to is probably the "Submit item for publishing" event, which, as you figured out, ends once the page is sent to the publishing queue.

The event you want to listen to is on the PublishTransaction object, as mentioned in this response.

Basically, you should check whenever a PublishTransaction is updated for the transaction status. Once it's complete (i.e. PublishTransactionState.Success) you will know that publishing has finished successfully.

I might be off the mark here, but why not use something like SI4T instead?

4

I am not quite in agreement with your findings. In addition to what Nuno has said, the Deployer Extension in the Post-Transaction will get executed after the Publishing Transaction is committed. You may want to check the methodology that you are using to retrieve the content if you are receiving an older version of it. Further since you are using SDL Tridion 2013 and you really want to deal with the published content's storage in some other storage (Custom DB), it makes more sense and efficient that you make use of Storage Extension.

If you really don't care about the best possible approach (as there may specific business context, opinions etc.) below is full list in order of their recommendation to accomplish the task:

  • Storage Extension - Write a Storage Extension for File System, retrieve the mark up of the page and delegate the job of storing it in custom DB to some other service or whatever suits you
  • Deployer Extension (Post Transaction Phase): Write a Deployer Extension and configure it to run in the Post Transaction phase. Retrieve the mark up of the published page and manipulate it.
  • Event System
4

To my knowledge data is stored in the commitTransaction operation in the storage layer so extending this by calling the base operation and after that making your query to the webserver should yield the desired results.

For this to work you would have to create a storage extension (not a deployer extension!); i believe Will explains how the factory commits the changes here

Conceptually this would look something linke

public class IndexingJPADAOFactory extends JPADAOFactory {
  public void commitTransaction(String transactionId) throws StorageException {
    try {
      super.commitTransaction(transactionId);
      indexPublishedPages(transactionId);
    }
      catch (StorageException storageException) {
      throw storageException;
    }
      catch (Exception indexingException) {
      log.error("Error indexing content: " + indexingException.getMessage());
    }
  }
}

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.