Class OrderSubmittedInventoryAdjustmentMessageListener

java.lang.Object
com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
com.broadleafcommerce.inventory.service.messaging.checkout.OrderSubmittedInventoryAdjustmentMessageListener

@DataRouteByKey("inventory") public class OrderSubmittedInventoryAdjustmentMessageListener extends AbstractInventoryAdjustmentListener
Message Listener to listen for submitted orders, parse them, and create HARD_RESERVATION InventoryTransaction (i.e. HARD Reservations).
Author:
Kelly Tisdell (ktisdell), Nathan Moore (nathandmoore)
  • Field Details

  • Constructor Details

    • OrderSubmittedInventoryAdjustmentMessageListener

      public OrderSubmittedInventoryAdjustmentMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, SkuInventoryService<SkuInventory> skuInventoryService, CartProvider cartProvider)
  • Method Details

    • listen

      @StreamListener("checkoutCompletionInputInventory") public void listen(org.springframework.messaging.Message<String> message)
    • processMessage

      public void processMessage(@NonNull @NonNull org.springframework.messaging.Message<String> message)
      Processes the received message by extracting fields relevant for recording inventory adjustments.
      Parameters:
      message - The checkout completion message received with payload
    • buildSkuInventoryReservationRequest

      protected SkuInventoryReservationRequest buildSkuInventoryReservationRequest(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds the SkuInventoryReservationRequest based on the fulfillment info in the checkout completion message.
      Parameters:
      jsonContext - a DocumentContext representation of the checkout completion message payload
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The SkuInventoryReservationRequest based on the fulfillment info in the checkout completion message.
    • buildRequestedItems

      protected List<SkuInventoryAdjustmentRequestItem> buildRequestedItems(@NonNull @NonNull Map<String,? extends CartItem> cartItems, @NonNull @NonNull List<? extends FulfillmentItem> fulfillmentItems)
      Iterates over the fulfillmentItems to determine for which a SkuInventoryAdjustmentRequestItem should be made.
      Parameters:
      cartItems - The cart line items with the merchandise information
      fulfillmentItems - The fulfillment items corresponding to the cartItems that represent the fulfillment information for those particular line items. These contain the information necessary to determine whether to build a SkuInventoryAdjustmentRequestItem.
      Returns:
      A list of SkuInventoryReservationRequestItems that should be handled by the inventory service
    • buildSkuInventoryAdjustmentItem

      protected SkuInventoryAdjustmentRequestItem buildSkuInventoryAdjustmentItem(FulfillmentItem fulfillmentItem, CartItem cartItem)
      Builds a SkuInventoryAdjustmentRequestItem with data from provided objects.
      Parameters:
      fulfillmentItem - the fulfillment item
      cartItem - the cart item
      Returns:
      the built sku inventory adjustment item
    • isSerialized

      protected boolean isSerialized(CartItem cartItem)
      Determines whether the cart item has a serialized sku inventory object
      Parameters:
      cartItem - the cart item
      Returns:
      whether the cart item has a serialized sku inventory object
    • buildSerializedSku

      protected String buildSerializedSku(CartItem cartItem)
      Builds a sku with an appended serialization value parameter
      Parameters:
      cartItem - cart item to access values from
      Returns:
      sku with an appended serialization value parameter
    • getInventorySerializationValue

      @Nullable protected String getInventorySerializationValue(CartItem cartItem)
      Hook point to get the serialization value of a cart item

      By default, accesses a respective entry inside CartItem.getInternalAttributes().

      Parameters:
      cartItem - the cart item
      Returns:
      the serialization value
    • getCartItemsWithDependentItems

      protected List<CartItem> getCartItemsWithDependentItems(String cartItemLink, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCartProvider

      protected CartProvider getCartProvider()