Broadleaf Microservices
  • v1.0.0-latest-prod

Recommendation Engine Service

Overview

This service exposes listeners for messages that are concerned with the following entities: products, customers, and orders. The service saves this information into a relational data structure which is then utilized by an Apache Spark Job to generate recommendations.

Catalog Information

The recommendation engine works off of its own representation of a catalog item - typically sourced from data coming from Broadleaf’s Catalog Service.

The recommendation engine stores catalog information in the following tables:

  • blc_application

  • blc_application_catalog

  • blc_catalog

  • blc_catalog_item

  • blc_catalog_ref

Syncing Product Changes to the Recommendation Engine

The recommendation service contain message listeners for product changes coming out of Broadleaf’s Catalog Microservice.

Specifically:

  • CatalogEntityCreatedEvent

  • CatalogEntityUpdatedEvent

  • CatalogEntityDeletedEvent

See com.broadleafcommerce.recommendationengine.service.messaging.CatalogItemEventListener for more details.

Broadleaf’s Catalog Service DOES NOT automatically send out these events by default. You will explicitly need to enable the following property in your Flex Package that contains your Catalog microservice:

broadleaf:
  propagation:
    allowCatalogEntityCreationNotification: true
    allowCatalogEntityUpdateNotification: true
    allowCatalogEntityDeleteNotification: true
Note
you can add the above to the config/insecure properties file for the appropriate flex package (e.g. one.yml) for your Config Service. Once added, you will need to cycle your flex package for this configuration to be picked up.
Warning
Take care when enabling this property as this may not be the best solution for your implementation. For example, if your implementation is prone to have a lot of catalog/product churn then turning these properties on may become too "noisy" over time. Instead, you may want to opt for a more custom asynchronous approach using a custom scheduled job that may run nightly for example.

Customer Information

The recommendation service contain message listeners for customer changes coming out of Broadleaf’s Customer Microservice.

Specifically:

  • CustomerModifiedEvent

See com.broadleafcommerce.recommendationengine.service.messaging.CustomerEventListener and recommendationengine-defaults.yml for more details around the Spring Cloud Stream binding setup and message implementation.

Broadleaf’s Customer Service DOES NOT automatically send out this event by default. You will explicitly need to enable the following property in your Flex Package that contains your Customer microservice:

broadleaf:
  customer:
    messaging:
      customer-modified:
        active: true

The recommendation engine stores customer information in the following tables:

  • blc_customer_reference

Order Information

The recommendation service contain message listeners for order creation events coming out of Broadleaf’s Order Microservice.

Specifically:

  • PurchaseEvent

See com.broadleafcommerce.recommendationengine.service.messaging.PurchaseEventListener and recommendationengine-defaults.yml for more details around the Spring Cloud Stream binding setup and message implementation.

The recommendation engine stores purchase information in the following tables:

  • blc_purchase

  • blc_purchase_item

Recommendations Endpoint

This service also exposes an endpoint (i.e. /product-recommendations) to fetch recommendations for a customer i.e. it has the ability to grab the top "X" number of recommendations for a customer (based on what’s requested on the customer context header)

See com.broadleafcommerce.recommendationengine.web.endpoint.RecommendationEngineEndpoint for more details.