Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,7 @@ Use `deploy.sh` again to tear down the OpenWhisk actions, triggers, and rules. Y
# 5. Recreate deployment manually
This section provides a deeper look into what the `deploy.sh` script executes so that you understand how to work with OpenWhisk triggers, actions, rules, and packages in more detail.

## 5.1 Bind Kafka package with credential parameters
Make the Kafka instance in Bluemix available as an event source.

```bash
wsk package refresh
wsk package create kafka
wsk package bind kafka kafka-out-binding \
--param api_key ${API_KEY} \
--param kafka_rest_url ${KAFKA_REST_URL} \
--param topic ${DEST_TOPIC}
wsk package get --summary kafka-out-binding
```

## 5.2 Create Kafka message trigger
## 5.1 Create Kafka message trigger
Create the `kafka-trigger` trigger that listens for new messages.

```bash
Expand All @@ -94,14 +81,14 @@ wsk trigger create kafka-trigger \
--param topic ${SRC_TOPIC}
```

## 5.3 Create action to consume message
## 5.2 Create action to consume message
Upload the `mhget-action` action as a single file Node.js action. This downloads messages when they arrive via the trigger.

```bash
wsk action create mhget-action actions/mhget/mhget.js
```

## 5.4 Create action to aggregate and send back message
## 5.3 Create action to aggregate and send back message
Upload the `mhpost-action` action as a zipped action, in order to include dependencies that are not in the default Node.js environment on OpenWhisk. This aggregates information from the action above, and sends the summary JSON back to Kafka.

```bash
Expand All @@ -110,17 +97,20 @@ cd actions/mhpost
npm install --loglevel=error
zip -r mhpost.zip *
cd ${DIR}
wsk action create kafka/mhpost-action actions/mhpost/mhpost.zip --kind nodejs:6
wsk action create mhpost-action actions/mhpost/mhpost.zip --kind nodejs:6 \
--param api_key ${API_KEY} \
--param kafka_rest_url ${KAFKA_REST_URL} \
--param topic ${DEST_TOPIC}
```

## 5.5 Create sequence that links get and post actions
## 5.4 Create sequence that links get and post actions
Declare a linkage between the `mhget-action` and `mhpost-action` in a sequence named `kafka-sequence`.

```bash
wsk action create kafka-sequence --sequence mhget-action,kafka-out-binding/mhpost-action
wsk action create kafka-sequence --sequence mhget-action,mhpost-action
```

## 5.6 Create rule that links trigger to sequence
## 5.5 Create rule that links trigger to sequence
Declare a rule named `kafka-inbound-rule` that links the trigger `kafka-trigger` to the sequence named `kafka-sequence`.

```bash
Expand Down
22 changes: 7 additions & 15 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ function usage() {
function install() {
echo -e "Installing OpenWhisk actions, triggers, and rules for openwhisk-data-processing-message-hub..."

echo "Creating package binding for the Bluemix Kafka service"
wsk package refresh
wsk package create kafka
wsk package bind kafka kafka-out-binding \
--param api_key ${API_KEY} \
--param kafka_rest_url ${KAFKA_REST_URL} \
--param topic ${DEST_TOPIC}
wsk package get --summary kafka-out-binding

echo "Creating the kafka-trigger trigger"
wsk trigger create kafka-trigger \
--feed /_/Bluemix_${KAFKA_INSTANCE_NAME}_Credentials-1/messageHubFeed \
Expand All @@ -49,10 +40,13 @@ function install() {
npm install --loglevel=error
zip -r mhpost.zip *
cd ${DIR}
wsk action create kafka/mhpost-action actions/mhpost/mhpost.zip --kind nodejs:6
wsk action create mhpost-action actions/mhpost/mhpost.zip --kind nodejs:6 \
--param api_key ${API_KEY} \
--param kafka_rest_url ${KAFKA_REST_URL} \
--param topic ${DEST_TOPIC}

echo "Creating the kafka-sequence sequence that links the get and post actions"
wsk action create kafka-sequence --sequence mhget-action,kafka-out-binding/mhpost-action
wsk action create kafka-sequence --sequence mhget-action,mhpost-action

echo "Creating the kafka-inbound-rule rule that links the trigger to the sequence"
wsk rule create kafka-inbound-rule kafka-trigger kafka-sequence
Expand All @@ -64,13 +58,11 @@ function install() {
function uninstall() {
echo -e "Uninstalling..."

wsk rule delete --disable kafka-inbound-rule
wsk rule delete --disable kafka-inbound-rule
wsk trigger delete kafka-trigger
wsk action delete kafka-sequence
wsk action delete mhget-action
wsk action delete kafka/mhpost-action
wsk package delete kafka-out-binding
wsk package delete kafka
wsk action delete mhpost-action

echo -e "Uninstall Complete"
}
Expand Down