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)
-
Nested Class Summary
Nested classes/interfaces inherited from class com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
AbstractInventoryAdjustmentListener.OrderFulfillment, AbstractInventoryAdjustmentListener.OrderFulfillmentItem, AbstractInventoryAdjustmentListener.OrderItem
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
The path to the cart item link.static final String
Deprecated.since 1.5.static final String
The path to the fulfillment group link.static final String
Deprecated.since 1.5.static final String
static final String
Fields inherited from class com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
APPLICATION_ID_PATH, INVENTORY_SERIALIZATION_VALUE, TENANT_ID_PATH
-
Constructor Summary
ConstructorsConstructorDescriptionOrderSubmittedInventoryAdjustmentMessageListener
(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, SkuInventoryService<SkuInventory> skuInventoryService, CartProvider cartProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<SkuInventoryAdjustmentRequestItem>
buildRequestedItems
(@NonNull Map<String, ? extends CartItem> cartItems, @NonNull List<? extends FulfillmentItem> fulfillmentItems) Iterates over thefulfillmentItems
to determine for which aSkuInventoryAdjustmentRequestItem
should be made.protected String
buildSerializedSku
(CartItem cartItem) Builds a sku with an appended serialization value parameterprotected SkuInventoryAdjustmentRequestItem
buildSkuInventoryAdjustmentItem
(FulfillmentItem fulfillmentItem, CartItem cartItem) Builds aSkuInventoryAdjustmentRequestItem
with data from provided objects.protected SkuInventoryReservationRequest
buildSkuInventoryReservationRequest
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds theSkuInventoryReservationRequest
based on the fulfillment info in the checkout completion message.getCartItemsWithDependentItems
(String cartItemLink, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProvider
protected String
getInventorySerializationValue
(CartItem cartItem) Hook point to get the serialization value of a cart itemprotected boolean
isSerialized
(CartItem cartItem) Determines whether the cart item has a serialized sku inventory objectvoid
void
processMessage
(@NonNull org.springframework.messaging.Message<String> message) Processes the received message by extracting fields relevant for recording inventory adjustments.Methods inherited from class com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
buildContextInfo, buildContextInfo, getDocumentContext, getIdempotentConsumptionService, getSkuInventoryService, getSkuReferenceFieldType, getTypeFactory
-
Field Details
-
SUBMITTED_STATUS
- See Also:
-
CART_ID_PATH
- See Also:
-
ORDER_STATUS_PATH
- See Also:
-
CART_ITEMS_PATH
Deprecated.since 1.5. Cart items now need to be read from the cart service. SeeCartProvider
andCART_ITEM_LINK_PATH
- See Also:
-
FULFILLMENT_GROUPS_PATH
Deprecated.since 1.5. Fulfillment groups now need to be read from the cart service. SeeCartProvider
andFULFILLMENT_GROUP_LINK_PATH
- See Also:
-
CART_ITEM_LINK_PATH
The path to the cart item link. This link must be used to retrieve cart items via GET request to the cart service.- See Also:
-
FULFILLMENT_GROUP_LINK_PATH
The path to the fulfillment group link. This link must be used to retrieve fulfillment groups via GET request to the cart service.- See Also:
-
-
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
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 theSkuInventoryReservationRequest
based on the fulfillment info in the checkout completion message.- Parameters:
jsonContext
- aDocumentContext
representation of the checkout completion message payloadcontextInfo
- 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 thefulfillmentItems
to determine for which aSkuInventoryAdjustmentRequestItem
should be made.- Parameters:
cartItems
- The cart line items with the merchandise informationfulfillmentItems
- The fulfillment items corresponding to thecartItems
that represent the fulfillment information for those particular line items. These contain the information necessary to determine whether to build aSkuInventoryAdjustmentRequestItem
.- Returns:
- A list of
SkuInventoryReservationRequestItems
that should be handled by the inventory service
-
buildSkuInventoryAdjustmentItem
protected SkuInventoryAdjustmentRequestItem buildSkuInventoryAdjustmentItem(FulfillmentItem fulfillmentItem, CartItem cartItem) Builds aSkuInventoryAdjustmentRequestItem
with data from provided objects.- Parameters:
fulfillmentItem
- the fulfillment itemcartItem
- the cart item- Returns:
- the built sku inventory adjustment item
-
isSerialized
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
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
Hook point to get the serialization value of a cart itemBy default, accesses a respective entry inside
CartItem.getInternalAttributes()
.- Parameters:
cartItem
- the cart item- Returns:
- the serialization value
-
getCartItemsWithDependentItems
-
getCartProvider
-