Skip to content

Commit

Permalink
Consolidate serverless workflow newsletter-subscription example
Browse files Browse the repository at this point in the history
  • Loading branch information
nmirasch committed Feb 8, 2024
1 parent 4d81979 commit a086910
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,98 @@ spec:
value: "http-events-support"
- name: QUARKUS_HTTP_PORT
value: "8080"
- name: KOGITO_SERVICE_URL
value: http://data-index-service-postgresql
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-processes-trigger
name: data-index-service-postgresql-process-definition-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceEvent
type: ProcessDefinitionEvent
subscriber:
ref:
apiVersion: v1
kind: Service
name: data-index-service-postgresql
uri: /definitions
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-process-error-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceErrorDataEvent
subscriber:
ref:
apiVersion: v1
kind: Service
name: data-index-service-postgresql
uri: /processes
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-process-node-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceNodeDataEvent
subscriber:
ref:
apiVersion: v1
kind: Service
name: data-index-service-postgresql
uri: /processes
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-process-sla-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceSLADataEvent
subscriber:
ref:
apiVersion: v1
kind: Service
name: data-index-service-postgresql
uri: /processes
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-process-state-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceStateDataEvent
subscriber:
ref:
apiVersion: v1
kind: Service
name: data-index-service-postgresql
uri: /processes
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: data-index-service-postgresql-process-variable-trigger
spec:
broker: default
filter:
attributes:
type: ProcessInstanceVariableDataEvent
subscriber:
ref:
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: KOGITO_SERVICE_URL
value: http://jobs-service-postgresql
- name: JOBS_SERVICE_PERSISTENCE
value: "postgresql"
- name: KOGITO_JOBS_SERVICE_HTTP_JOB_STATUS_CHANGE_EVENTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,19 @@ quarkus.datasource.password=${POSTGRES_PASSWORD:pass}

# Events produced by kogito-addons-quarkus-jobs-knative-eventing to program the timers on the jobs service.
mp.messaging.outgoing.kogito-job-service-job-request-events.connector=quarkus-http
# The K_SINK variable is automatically injected by the Knative ecosystem. The default value http://localhost:8280
# is used for local testing.
mp.messaging.outgoing.kogito-job-service-job-request-events.url=${K_SINK:http://localhost:8280/v2/jobs/events}
mp.messaging.outgoing.kogito-job-service-job-request-events.method=POST

# process, variables and user tasks events configuration.
mp.messaging.outgoing.kogito-processinstances-events.connector=quarkus-http
mp.messaging.outgoing.kogito-processinstances-events.url=${K_SINK:http://localhost:8180/processes}
mp.messaging.outgoing.kogito-processinstances-events.method=POST

kogito.events.usertasks.enabled=false
mp.messaging.outgoing.kogito-usertaskinstances-events.connector=quarkus-http
mp.messaging.outgoing.kogito-usertaskinstances-events.url=${K_SINK:http://localhost:8180/tasks}
mp.messaging.outgoing.kogito-usertaskinstances-events.method=POST

kogito.events.variables.enabled=false
mp.messaging.outgoing.kogito-variables-events.connector=quarkus-http
mp.messaging.outgoing.kogito-variables-events.url=${K_SINK:http://localhost:8180/variables}
mp.messaging.outgoing.kogito-variables-events.method=POST

mp.messaging.outgoing.kogito-processdefinitions-events.connector=quarkus-http
mp.messaging.outgoing.kogito-processdefinitions-events.url={K_SINK:http://localhost:8180/definitions}
mp.messaging.outgoing.kogito-processdefinitions-events.method=POST
kogito.addon.messaging.outgoing.cloudEventMode=structured

## Knative integration:

# Use the Kogito service discovery mechanism to get the subscription-service url and set an env var with name SUBSCRIPTION_SERVICE_URL
# Use the Kogito service discovery mechanism to get the subscription-service url
# For more information see:
# https://kiegroup.github.io/kogito-docs/serverlessworkflow/latest/cloud/kubernetes-service-discovery.html
# https://quarkus.io/guides/deploying-to-kubernetes#environment-variables-from-keyvalue-pairs
quarkus.knative.env.vars.subscription_service_url=${knative:services.v1.serving.knative.dev/newsletter-showcase/subscription-service}
quarkus.rest-client.subscription_service_yaml.url=${knative:services.v1.serving.knative.dev/newsletter-showcase/subscription-service}

# Configure current deployment to set an env var with name POSTGRES_HOST
# For more information see: https://quarkus.io/guides/deploying-to-kubernetes#environment-variables-from-keyvalue-pairs
Expand All @@ -84,7 +66,9 @@ quarkus.knative.env.vars.postgres_host=newsletter-postgres
# you can change this property with -Pknative -Dquarkus.container-image.group from the command line.
quarkus.container-image.group=dev.local
quarkus.kubernetes.deployment-target=knative
# The name of the application. This value will be used for naming Kubernetes resources like: Deployment, Service, etc.
quarkus.knative.name=subscription-flow
quarkus.container-image.name=${quarkus.knative.name}
quarkus.knative.image-pull-policy=IfNotPresent

# Kogito Knative integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ quarkus.log.category."org.kie.kogito.addon.quarkus.messaging".level=DEBUG
# Internally, Kogito Serverless Workflow uses the Quarkus OpenAPI Generator extension.
# The default value http://localhost:8282 is used for local testing. In kubernetes environments, the env var
# SUBSCRIPTION_SERVICE_URL will be used instead. This env var is configured in the application-knative.properties file.
quarkus.rest-client.subscription_service_yaml.url=${SUBSCRIPTION_SERVICE_URL:http://localhost:8282}
quarkus.rest-client.subscription_service_yaml.url=http://localhost:8282

mp.messaging.incoming.kogito_incoming_stream.connector=quarkus-http
mp.messaging.incoming.kogito_incoming_stream.path=/
Expand All @@ -48,22 +48,6 @@ mp.messaging.outgoing.kogito_outgoing_stream.url=${K_SINK:http://localhost:8181}
%container.quarkus.container-image.registry=dev.local
%container.quarkus.container-image.tag=1.0-SNAPSHOT

# process, variables and user tasks events configuration.
mp.messaging.outgoing.kogito-processinstances-events.connector=quarkus-http
mp.messaging.outgoing.kogito-processinstances-events.url=http://localhost:8180/processes
mp.messaging.outgoing.kogito-processinstances-events.method=POST

kogito.events.usertasks.enabled=false
mp.messaging.outgoing.kogito-usertaskinstances-events.connector=quarkus-http
mp.messaging.outgoing.kogito-usertaskinstances-events.url=http://localhost:8180/tasks
mp.messaging.outgoing.kogito-usertaskinstances-events.method=POST

kogito.events.variables.enabled=false
mp.messaging.outgoing.kogito-variables-events.connector=quarkus-http
mp.messaging.outgoing.kogito-variables-events.url=http://localhost:8180/variables
mp.messaging.outgoing.kogito-variables-events.method=POST

# process definitions events configuration.
mp.messaging.outgoing.kogito-processdefinitions-events.connector=quarkus-http
mp.messaging.outgoing.kogito-processdefinitions-events.url=http://localhost:8180/definitions
mp.messaging.outgoing.kogito-processdefinitions-events.method=POST

0 comments on commit a086910

Please sign in to comment.