Skip to main content

Streaming-Lite

This quickstart describes how to install Nussknacker with Streaming-Lite engine using helm and Kubernetes and goes through sample scenarios.

Prerequisites

  • helm, kubectl (more or less latest version) installed
  • access to Kubernetes cluster
    • for local installation with k3d see below
    • cluster should have ingress configured

Running on local K3d

If you don't have K8s available, we recommend installing k3d. Instructions below assume that the cluster was created with ingress port mapped to 8081 - see guide for the details.

Running

  • Clone Nussknacker-quickstart project from GitHub.
  • Enter k8s-helm directory.
  • If you have configured TLD connected to your ingress (not applicable with e.g. k3d setup), set DOMAIN parameter in .env file.
  • Install additional services, not included in standard chart (AKHQ and sample customer service) with ./additional/install.sh. Wait until they're running.
  • Run ./k8s-helm/install.sh and wait until all components start.
note

In all links below we assume using k3d setup, described above. If you use ingress with TLD configured, please replace http://localhost:8081 with http(s)://nu-quickstart-nussknacker.$DOMAIN/ in all links below.

Now you are ready to check your newly created environment:

Defining a new scenario

  • Go to Nussknacker
  • Click 'Create new scenario' button - name it 'DetectLargeTransactions'
  • You'll see an empty workspace
  • Run ./k8s-helm/scripts/createSchemas.sh to create Schema Registry subjects - you can see them on AKHQ
  • Click 'Import' on right panel and upload 'k8s-helm/scenarios/DetectLargeTransactionsLite.json'

This scenario reads transactions data from Kafka, filters only those with amount greater than some value and writes filtered events back to Kafka.

  • Double-click on nodes to see scenario logic
  • Click 'Save'

You have just created your first scenario!

Test scenario with data

  • Click 'Deploy' on the right panel
  • Wait until deployment status shows running
  • Run ./k8s-helm/scripts/sendTestTransactions.sh script a few times to generate some data

The first run may end with error from Kafka - don't worry about it. Script will send some json data to "transactions" Kafka topic.

  • Go to Metrics tab on Nussknacker main panel - you should see changed metrics.

Your scenario just processed data from Kafka and saved filtered results!

Producing events manually

  • In more controlled way, you can use AKHQ installed in quickstart setup (it's not part of the default NU installation). Go to Data tab
  • Double-click on 'transactions' topic name and then 'Produce to topic'
  • In a form you can set desired parameters of the event e.g. event key and value
  • Please note that the events have to adhere to schema, otherwise you'll get runtime errors.

See results

Test your scenario in a sandbox

  • Clink 'generate' button in right panel of application

If you followed the Quickstart from the beginning you should have some data on Kafka by now. Most recent records from Kafka will be downloaded to a file.

  • Click 'from file' button and upload file generated in last step
  • After a while you will see test results - how many records passed filters, and what where variables values

Add more behaviour to the scenario

After creating and running basic scenario it's time to add more sophisticated behaviour - in this (optional) section you'll see how to use a bit more complex components. After each step you can deploy, test and see modified results.

Integration with external system

In next step we'll see how to enrich data using external system, exposing customer data via OpenAPI. We implemented sample service in python (see customerservice folder), to show you don't have use Java to integrate with Nussknacker.

You can look at k8s-helm/values.yaml file (look for components.openAPI setting) to see how easy it is to configure additional OpenAPI services.

Click 'Import' on right panel and upload 'k8s-helm/scenarios/DetectLargeTransactionsWithEnricherLite.json'

You can see how we use new Enricher getcustomer to retrieve additional customer data to be able to categorize suspicious situations based on customer category

On the video you can see how Nussknacker detect fields from external service and how you can see metrics for OpenAPI intergration.

Correcting errors

In turns out that integration added in last step does not handle some cases well - namely, transaction may come from unknown customer, in this case customer service returns empty message.

Watch video to see how to use tests to detect and correct such situations, also - how to detect unexpected problems with external service (our sample implementation throws error from time to time):