Alex Clark
Alex Clark

Reputation: 213

Broadleaf Commerce - My workflow activities are being executed twice

It seems that the built in workflow activities are being executed twice. I am testing the checkout workflow and the DecrementInventoryActivity is removing the quantity from the sku twice.

Is this a known bug or am I doing something wrong?

I created the workflow like so:

<!-- Checkout Workflow Configuration -->
<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
   <property name="processContextFactory">
      <bean class="org.broadleafcommerce.core.checkout.service.workflow.CheckoutProcessContextFactory"/>
   </property>
   <property name="activities">
      <list>
         <bean p:order="6000" id="blDecrementInventoryActivity" class="org.broadleafcommerce.core.checkout.service.workflow.DecrementInventoryActivity">
            <property name="rollbackHandler" ref="blDecrementInventoryRollbackHandler" />
         </bean>
         <bean p:order="7000" id="blCompleteOrderActivity" class="org.broadleafcommerce.core.checkout.service.workflow.CompleteOrderActivity">
            <property name="rollbackHandler" ref="blCompleteOrderRollbackHandler" />
         </bean>
         <bean p:order="9999999" class="com.mycompany.workflow.checkout.NotifyExternalInventorySystem" />
      </list>
   </property>
   <property name="defaultErrorHandler">
      <bean class="org.broadleafcommerce.core.workflow.DefaultErrorHandler">
         <property name="unloggedExceptionClasses">
            <list>
               <value>org.broadleafcommerce.core.inventory.service.InventoryUnavailableException</value>
            </list>
         </property>
      </bean>
    </property>
</bean>

Upvotes: 0

Views: 73

Answers (1)

phillipuniverse
phillipuniverse

Reputation: 2045

Starting with Broadleaf 4.0, the DecrementInventoryActivity was added by default to the blCheckoutWorkflow. See the 3.1.10-4.0.0 migration notes at http://www.broadleafcommerce.com/docs/core/4.0/migration-notes/3.1-to-4.0-migration/3.1.10-to-4.0-migration, in the section "Inventory Management".

This also goes for the defaultErrorHandler, and you can remove the blCompleteOrderActivity (that has always been managed in the framework). Basically, your customized blCheckoutWorkflow bean should change to:

<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
   <property name="activities">
      <list>
         <bean p:order="9999999" class="com.mycompany.workflow.checkout.NotifyExternalInventorySystem" />
      </list>
   </property>
</bean>

Starting with Broadleaf 3.0, any modifications to the blCheckoutWorkflow bean undergo the Broadleaf XML merging processing (which merges bean ids like blCheckoutWorkflow's list of activities). In your case, since the DecrementInventoryActivity is already defined in the core framework XML file and your definition of blCheckoutWorkflow merges with it, the final result is 2 instances of the DecrementInventoryActivity.

Upvotes: 1

Related Questions