Extension Point: Order Release Events
Basics
Parameter | Value |
---|---|
Extension Point Key | ORDER_RELEASE_EVENT |
Extension Point Name | Order Release Event |
Extension Interface | OrderReleaseEvent |
Supports Multiple Extensions? | Yes |
Selector Type | None |
Available Since | 1.3.0 |
Use Cases
Extensions implementing this Extension Point are notified when purchases are confirmed and ready to be sent to the fulfillment system.
Methods
getDeliveryPolicy
The getDeliveryPolicy
method is invoked during Integration Server startup. It allows the extension to define how retries should be handled if the extension throws an exception. The extension needs to return the following values in the XPFDeliveryPolicy
response object:
consumerQueueName
: An identifier for the consumer message queue that will be used to track events and allow them to be processed asynchronously. This value should be unique for all extensions assigned to this extension point.maximumRedeliveries
: The maximum number of redelivery attempts before the message is sent to the dead letter queue.redeliveryDelay
: The delay between redelivery attempts, in milliseconds.
release
The release
method is invoked when an order is ready to be released for fulfillment.
Orders can be released in the following ways:
- Orders containing only non-physical line items are released immediately.
- Orders containing one or more physical line item are automatically released by the Release Shipments Quartz job.
- Orders containing one or more physical line item can be manually released by clicking the "Release Shipment" button in Commerce Manager.
Orders transition from the CREATED
to IN_PROGRESS
status when they are released.
Extension Sample
@SuppressWarnings("checkstyle:magicnumber")
@Extension
@XPFAssignment(extensionPoint = XPFExtensionPointEnum.ORDER_RELEASE_EVENT, priority = 100)
public class SegmentOrderRelease extends XPFExtensionPointImpl implements OrderReleaseEvent {
@Override
public XPFDeliveryPolicy getDeliveryPolicy() {
XPFDeliveryPolicy xpfDeliveryPolicy = new XPFDeliveryPolicy();
xpfDeliveryPolicy.setConsumerQueueName("segment");
xpfDeliveryPolicy.setMaximumRedeliveries(10);
xpfDeliveryPolicy.setRedeliveryDelay(10000); // 10 seconds
return xpfDeliveryPolicy;
}
@Override
public void release(final XPFOrderReleaseEventContext xpfOrderReleaseEventContext) {
Analytics analytics = (Analytics) XPFExternalPlugin.getInstance().getContext().getCustomData().get("analytics");
if (analytics != null) {
XPFOrder order = xpfOrderReleaseEventContext.getOrder();
analytics.enqueue(TrackMessage.builder("Order released")
.userId(order.getCustomer().getSharedId())
.properties(ImmutableMap.<String, Object>builder()
.put("orderNumber", order.getOrderNumber())
.put("storeCode", order.getStore().getCode())
.put("currency", order.getCurrency().getCurrencyCode())
.put("revenue", order.getTotal().doubleValue())
.build())
);
}
}
}