Solution walkthrough

1. Under the hood: Step through Review moderation flow

  1. Navigate to streams for Apache Kafka console. Filter for the term reviews to view 3 related topics.

  2. Click on the globex.reviews topic to see an Overview of the topic page

    amqstreams globex reviews topic overview
  3. Click on any of the message to view the complete message payload

    amqstreams globex reviews topic detail
  4. Click on the headers tab and take note of the headers of the message. This is what each of them mean:

    amqstreams globex reviews headers
    1. ce_id: 1 - This is a unique id for each message.

    2. ce_source: submit-review and ce_type: submit-review-event - These are the primary values which are used by the Knative triggers to route the message to the right Knative service.

  5. Navigate back to the {openshift_cluster_console}/topology/ns/globex-serverless-{user_name}?view=graph[Topology View, window="console"], to view the corresponding mapping in the Knative Broker and Triggers

    1. Click on the blue link (highlighted in blue below) pointing to aiml-moderate-reviews service. This link represents the moderate-reviews-trigger.

    2. The right-hand panel shows the trigger’s source = submit-review and type = submit-review-event.

    3. You will note that this matches the CloudEvents headers in the Kafka message that you viewed in streams for Apache Kafka Console browser.

    4. This is how the Knative Triggers match the messages to the right endpoint.

      moderate reviews trigger
  6. Once the reviews are sent to the aiml-moderate-reviews (Python) service, it uses the Hate-speech-CNERG/english-abusive-MuRIL AI/ML model to identify if the product review is abusive or not.

    1. A score of -1 is assigned if the review is acceptable or 0 if the comment is abusive.

    2. This service then POSTs the review with the score to the moderated-reviews-sink (with the help of the ServiceBinding which binds the sink to the services).

      moderated reviews sink
    3. This sink is configured to write to the reviews.moderated topic. Here is a sample message of how a moderated review (kafka message) looks like in the streams for Apache Kafka console.

      amqstreams moderate review score
  7. Next, the message is sent to the persist-reviews Quarkus service through the persist-reviews-trigger trigger. This service persists the review in a Postgresql DB if the score less than 0 (that is, the review is acceptable)

    1. Note that the trigger’s filter’s source and type matches the ce_type and ce_source headers of the message from the reviews.moderated topic shown in the screenshot above.

      persist reviews trigger

2. Under the hood: Review sentiment analysis

The Review sentiment analysis flow is quite similar to the Moderate Review flow.

review sentiment flow
  1. The sentiment-reviews-trigger responds to the same CloudEvents filter headers as the moderate-reviews-trigger; this is because when a review is submitted, they need to be processed by both the moderate and analyse services.

    sentiment reviews trigger
  2. The aiml-sentiment-reviews which is invoked, then uses the nlptown/bert-base-multilingual-uncased-sentiment to identify a score (from -1 to 4) depending on the tone of the review.

  3. The review is then sent to the reviews.sentiment topic. Access this topic in the streams for Apache Kafka console. Click on any of the kafka messages to view the sentiment score.

    amqstreams sentiment score

As a next step, this sentiment score can be used to build a dashboard to visualise the sentiment of various categories of products. This is out of the scope of this workshop, but here is a sample dashboard built using Grafana.

globex dashboard sample

3. Congratulations

Congratulations! With this you have completed the Event Driven Applications workshop module!

Please close all but the Workshop Deployer browser tab to avoid proliferation of browser tabs which can make working on other modules difficult.

Proceed to the Workshop Deployer to choose your next module.