Friday, October 3, 2014

ATG Pipeline Manager

The Pipeline Manager controls a series of processors, which make up a processor chain. Each processor in the processor chain is a component that performs a specific function and returns a status code. The status code can determine which processor to execute next.

The PipelineManager Nucleus component for ATG Commerce is located at /atg/commerce/PipelineManager. In ATG Consumer Commerce, the related XML configuration file is defined in <ATG9dir>/B2CCommerce/config/atg/commerce/commercepipeline.xml.

The following pipeline chains are defined in commercepipeline.xml.
  1. updateOrder Pipeline Chain: Saves the order supplied to it.
  2. loadOrder Pipeline Chain: Loads the order from the repository whose ID is supplied as a parameter.
  3. refreshOrder Pipeline Chain: Reloads an order after an error and causes the unloaded portion of an Order to be loaded when accessed.
  4. processOrder Pipeline Chain: Submits the given order for checkout.
  5. validateForCheckout Pipeline Chain: Verifies that the order is ready for checkout.
  6. validatePostApproval Pipeline Chain: Revalidates an order after approval.
  7. validatePaymentGroupsPostApproval Pipeline Chain: Validates each payment group in an order after the order has been approved.
  8. validateNoApproval Pipeline Chain: Validates an order that does not require approval.
  9. recalcPaymentGroupAmounts Pipeline Chain: Regenerates the amount that must be assigned to each PaymentGroup in the order.
  10. repriceOrder Pipeline Chain: Prices the order
  11. moveToConfirmation Pipeline Chain: Prices the order and validates it.
  12. moveToPurchaseInfo Pipeline Chain: Validates the order.
  13. validateShippingInfo Pipeline Chain: Validates the shipping groups in the order.
  14. sendScenarioEvent Pipeline Chain: Sends a message to the Dynamo Message System
/atg/commerce/invoice/pipeline/InvoicePipelineManager
/atg/commerce/payment/PaymentPipelineManager
/atg/commerce/PipelineManager


/atg/commerce/PipelineManager/

$class=atg.commerce.pipeline.CommercePipelineManager

# The location of the XML configuration file in the classpath.
# Default: /atg/commerce/CommercePipeline.xml
definitionFile=/atg/commerce/commercepipeline.xml


# The transaction manager that the PipelineManager will use to coordinate its
# transactions.
transactionManager=/atg/dynamo/transaction/TransactionManager

Steps to create pipeline:
1) update commercepipeline.xml
<pipelinechain name="moveToConfirmation" transaction="TX_REQUIRED" headlink="executeMyCustomChain" xml-combine="append">
      <pipelinelink name="executeMyCustomChain2" transaction="TX_MANDATORY">
         <processor jndi="/atg/commerce/order/processor/ExecuteValidateForCheckoutChain"/>
        <transition returnvalue="1" link="executeMyCustomChain3"/>
      </pipelinelink>
       <pipelinelink name="executeMyCustomChain3" transaction="TX_MANDATORY">
               <processor jndi="/com/test/processor/ProcessMyPipeline"/>
       </pipelinelink>     
       </pipelinechain>
2) CustomPipeline.properties
pipelineManager=/atg/commerce/PipelineManager
moveToConfirmationPipelineProcess=moveToConfirmation 
3) public class CustomPipelineFormHandler extends PaymentGroupFormHandler {
........................
public void runProcessMoveToConfirmation(DynamoHttpServletRequest pRequest,
            DynamoHttpServletResponse pResponse) {
            ............
PipelineResult result =  runProcess(moveToConfirmationPipelineProcess(), ....);
            processPipelineErrors(result);


Adding a Commerce Processor Using XML Combination

There are two ways to extend a pipeline defined for a PipelineManager. One is to copy the entire XML file into your CONFIG layer and make the necessary changes. The other way is to use XML combination. Using XML combination is the preferred approach. The example below demonstrates of how to use XML combination to modify a pipeline chain.

The XML below is a section of the processOrder pipeline chain as it appears out of the box.

<pipelinechain name="processOrder" transaction="TX_REQUIRED"
           headlink="executeValidateForCheckoutChain">
  <pipelinelink name="executeValidateForCheckoutChain" transaction="TX_MANDATORY">
     <processor
            jndi="/atg/commerce/order/processor/ExecuteValidateForCheckoutChain"/>
     <transition returnvalue="1" link="checkForExpiredPromotions"/>
  </pipelinelink>
  <pipelinelink name="checkForExpiredPromotions" transaction="TX_MANDATORY">
     <processor jndi="/atg/commerce/order/processor/CheckForExpiredPromotions"/>
     <transition returnvalue="1" link="removeEmptyShippingGroups"/>
</pipelinelink>

The following example demonstrates how to add a new processor called purgeExcessOrderData between the executeValidateForCheckoutChain and checkForExpiredPromotions processors in the processOrder pipeline chain. The following XML code should be added to your config layer.

The important sections of this code are the additions of the xml-combine attributes in the pipelinechain and pipelinelink tags. The pipelinechain tag indicates what is being appended to its contents. The pipelinelink tag for executeValidateForCheckoutChain indicates what is replacing its contents.

<pipelinemanager>
 <pipelinechain name="processOrder" transaction="TX_REQUIRED"
            headlink="executeValidateForCheckoutChain" xml-combine="append">
   <pipelinelink name="executeValidateForCheckoutChain" transaction="TX_MANDATORY"
         xml-combine="replace">
     <processor
           jndi="/atg/commerce/order/processor/ExecuteValidateForCheckoutChain"/>
     <transition returnvalue="1" link="purgeExcessOrderData"/>
   </pipelinelink>
   <pipelinelink name="purgeExcessOrderData" transaction="TX_MANDATORY">
     <processor jndi="/atg/commerce/order/processor/PurgeExcessOrderData"/>
     <transition returnvalue="1" link="checkForExpiredPromotions"/>
   </pipelinelink>
 </pipelinechain>
</pipelinemanager>

The purgeExcessOrderData processor’s transition is what the executeValidateForCheckoutChain's transition is in the base file within the commerce platform.


No comments:

Post a Comment