This project leverages Red Hat Integration - Camel K 1.4.
The implemented Integration exposes the following RESTful service endpoints:
/webhook/amqpbridge
:- Webhook ping endpoint through the
GET
HTTP method. - Sends RHOAM Admin/Developer Portal webhook XML event to an AMQP address (
RHOAM.WEBHOOK.EVENTS.QUEUE
) through thePOST
HTTP method.
- Webhook ping endpoint through the
/openapi.json
: returns the OpenAPI 3.0 specification for the service./q/metrics
: the Camel Quarkus MicroProfile metrics
-
Login to the OpenShift cluster
oc login ...
-
Create an OpenShift project or use your existing OpenShift project. For instance, to create
camel-quarkus
oc new-project camel-k-integrations --display-name="Red Hat Integration - Camel K integrations"
-
Install, via OLM, the
Red Hat Integration Camel-K
operator in thecamel-k-integrations
namespace- Create the
camel-k-integrations
operator groupoc create --save-config -f - <<EOF apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: camel-k-integrations-operatorgroup namespace: camel-k-integrations spec: targetNamespaces: - camel-k-integrations EOF
- Create the
Red Hat Integration - Camel-K
subscriptionoc create --save-config -f - <<EOF apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: red-hat-camel-k namespace: camel-k-integrations spec: channel: 1.4.x installPlanApproval: Automatic name: red-hat-camel-k source: redhat-operators sourceNamespace: openshift-marketplace EOF
- Verify the successful installation of the
Red Hat Integration - Camel-K
operatorwatch oc get sub,csv,installPlan
- Create the
-
Create an
allInOne
Jaeger instance.- IF NOT ALREADY INSTALLED:
- Install, via OLM, the
Red Hat OpenShift distributed tracing platform
(Jaeger) operator with anAllNamespaces
scope.⚠️ Needscluster-admin
privilegesoc create --save-config -f - <<EOF apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: jaeger-product namespace: openshift-operators spec: channel: stable installPlanApproval: Automatic name: jaeger-product source: redhat-operators sourceNamespace: openshift-marketplace EOF
- Verify the successful installation of the
Red Hat OpenShift distributed tracing platform
operatorwatch oc get sub,csv
- Install, via OLM, the
- Create the
allInOne
Jaeger instance.oc create --save-config -f - <<EOF apiVersion: jaegertracing.io/v1 kind: Jaeger metadata: name: jaeger-all-in-one-inmemory spec: allInOne: options: log-level: info strategy: allInOne EOF
- IF NOT ALREADY INSTALLED:
-
Create the
amqpbroker-connection-secret
containing the QUARKUS QPID JMS configuration options from theamqpbroker.properties
file. These options are leveraged by the Camel Quarkus AMQP extension to connect to an AMQP broker.⚠️ Replace values with your AMQP broker environment in theamqpbroker.properties
file.oc create secret generic amqpbroker-connection-secret \ --from-file=./config/amqpbroker.properties
-
Run the integration:
kamel run ./integrations/RhoamWebhookEventsHandlerApi.java
You should see an output similar to the following:
Modeline options have been loaded from source files Full command: kamel run ./integrations/RhoamWebhookEventsHandlerApi.java --name=rhoam-webhook-events-handler-api --dependency=camel:camel-quarkus-amqp --dependency=camel:camel-quarkus-direct --open-api=resources/api/openapi.json --resource=file:resources/api/openapi.json --resource=file:resources/map/generate-api-KO-response.adm --resource=file:resources/map/generate-api-OK-response.adm --trait=prometheus.enabled=true --trait=3scale.enabled=true --trait=tracing.enabled=true --config=secret:amqpbroker-connection-secret --property=api.resources.path=file:/etc/camel/resources integration "rhoam-webhook-events-handler-api" created
-
Get the OpenShift route hostname
URL="http://$(oc get route camel-quarkus-rhoam-webhook-handler-api -o jsonpath='{.spec.host}')"
-
Test the
/webhook/amqpbridge
endpoint-
GET /webhook/amqpbridge
:http -v $URL/webhook/amqpbridge
[...] HTTP/1.1 200 OK [...] Content-Type: application/json [...] server: envoy [...] x-forwarded-port: 80 x-forwarded-proto: http x-request-id: b99d5741-7781-45a5-ad8b-d74b9fe3eb78 { "status": "OK" }
-
POST /webhook/amqpbridge
:-
OK
response:echo '<?xml version="1.0" encoding="UTF-8"?> <event> <action>updated</action> <type>account</type> <object> <account> <id>6</id> <created_at>2021-05-14T20:22:53Z</created_at> <updated_at>2021-05-14T20:22:53Z</updated_at> <state>approved</state> <org_name>TestAccount</org_name> <extra_fields/> <monthly_billing_enabled>true</monthly_billing_enabled> <monthly_charging_enabled>true</monthly_charging_enabled> <credit_card_stored>false</credit_card_stored> <plans> <plan default="true"> <id>6</id> <name>Default</name> <type>account_plan</type> <state>hidden</state> <approval_required>false</approval_required> <setup_fee>0.0</setup_fee> <cost_per_month>0.0</cost_per_month> <trial_period_days/> <cancellation_period>0</cancellation_period> </plan> </plans> <users> <user> <id>9</id> <created_at>2021-05-14T20:22:53Z</created_at> <updated_at>2021-05-14T20:22:53Z</updated_at> <account_id>6</account_id> <state>pending</state> <role>admin</role> <username>admin</username> <email>[email protected]</email> <extra_fields/> </user> </users> </account> </object> </event>' | http -v POST $URL/webhook/amqpbridge content-type:'application/xml'
[...] HTTP/1.1 200 OK Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH Access-Control-Allow-Origin: * Access-Control-Max-Age: 3600 Content-Type: application/json RHOAM_EVENT_ACTION: updated RHOAM_EVENT_TYPE: account Set-Cookie: 0d5acfcb0ca2b6f2520831b8d4bd4031=f3580c9af577adb49be04813506f5ec6; path=/; HttpOnly breadcrumbId: 43EB8F0221CD24E-0000000000000002 transfer-encoding: chunked { "status": "OK" }
-
-
-
Test the
/openapi.json
endpointhttp -v $URL/openapi.json
[...] HTTP/1.1 200 OK Accept: */* [...] Content-Type: application/vnd.oai.openapi+json [...] breadcrumbId: DFB5B53061B9578-0000000000000002 transfer-encoding: chunked { "components": { "schemas": { "ErrorMessageType": { "description": "Error message type ", [...] "info": { "contact": { "name": "Jean Nyilimbibi" }, "description": "API that handles RHOAM Admin/Developer Portals webhook events", "license": { "name": "MIT License", "url": "https://opensource.org/licenses/MIT" }, "title": "RHOAM Webhook Events Handler API", "version": "1.0.0" }, "openapi": "3.0.2", [...] }, "servers": [ { "description": "API Backend URL", "url": "http://rhoam-webhook-events-handler-api.apps.jeannyil.sandbox1789.opentlc.com" } ] }
-
Test the
/q/metrics
endpointhttp -v $URL/q/metrics
[...] HTTP/1.1 200 OK Set-Cookie: afac851ba5d373e8e02a0326002ffd7c=bd72161e796b12be5de494520b6174c6; path=/; HttpOnly cache-control: private content-length: 28449 [...] # HELP application_camel_context_exchanges_total The total number of exchanges for a route or Camel Context # TYPE application_camel_context_exchanges_total counter application_camel_context_exchanges_total{camelContext="camel-1"} 6.0 [...] # HELP application_camel_route_count The count of routes. # TYPE application_camel_route_count gauge application_camel_route_count{camelContext="camel-1"} 6.0 # HELP application_camel_route_exchanges_completed_total The total number of completed exchanges for a route or Camel Context # TYPE application_camel_route_exchanges_completed_total counter application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="generate-error-response-route"} 0.0 application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="get-openapi-spec-route"} 1.0 application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="ping-webhook-route"} 1.0 application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="pingWebhook"} 1.0 application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="send-to-amqp-queue-route"} 4.0 application_camel_route_exchanges_completed_total{camelContext="camel-1",routeId="sendToAMQPQueue"} 4.0 [...] # HELP application_camel_route_exchanges_total The total number of exchanges for a route or Camel Context # TYPE application_camel_route_exchanges_total counter application_camel_route_exchanges_total{camelContext="camel-1",routeId="generate-error-response-route"} 0.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="get-openapi-spec-route"} 1.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="ping-webhook-route"} 1.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="pingWebhook"} 1.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="send-to-amqp-queue-route"} 4.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="sendToAMQPQueue"} 4.0 [...]