Pub/Sub hooks
You can create and use Pub/Sub hooks with ReachFive. This page introduces Pub/Sub hooks and instructs you on how to create one using the ReachFive Console.
Pub/Sub is an asynchronous messaging service that offers real-time message delivery along with reliable memory storage of the messages. Pub/Sub also decouples event production from event processing.
We will briefly look at the publisher-subscriber (Pub/Sub) relationship below.
If you don’t immmediately recognise the terms here, check out the important terms below. |
-
The publisher app connects to a topic in the Pub/Sub service. It then sends messages to this topic.
-
Messages are retained in message storage.
-
Messages are forwarded from the topic to all associated subscriptions individually.
-
The messages are transmitted by pushing to an endpoint or pulling from the service itself.
-
The subscriber application informs the Pub/Sub service that messages are received.
A major advantage of using Pub/Sub (as opposed to webhooks) is message storage (step 2 above) as well as subscriber acknowledgement of receiving the message (step 5 above). Until all subscriber applications have acknowledged receiving the message, Pub/Sub continues distributing the message to all relevant subscribers. This greatly improves guaranteed message delivery.
Create Pub/Sub hook from console
The Pub/Sub hook that you create in the ReachFive Console is triggered after an event is generated similar to that of a typical Post-event webhook.
Prerequisites
-
You must have access to the ReachFive Console.
-
You must have a Developer, Manager, or Administrator role.
-
You must have the Pub/Sub Hooks feature enabled.
Instructions
-
Log in to your ReachFive Console.
-
Go to
. -
Select New Pub/Sub hook or edit an existing Pub/Sub Hook.
-
Enable your Pub/Sub hook.
-
Give your hook a Key. This is a unique reference for the hook.
-
From the drop-down menu, choose the Event types that will trigger the Pub/Sub hook.
-
Optionally, add Filters to your hook.
Adding filters means only those fields matching the filter criteria are returned from the Pub/Sub hook. -
Choose the event fields and/or user fields you want to send in the request to your application. This is a comma-separated list.
User fields should be prefixed with user.
:email
→user.email
. -
Enter your Project ID for your Google Cloud account.
-
Enter the Topic where you want requests sent.
-
Enter the Credentials (in
JSON
format) needed to connect to Google Cloud. -
Don’t forget to Save your input.
View Pub/Sub results
To view the User Events, you should go to your Pub/Sub page in your Google Cloud Platform (GCP) account.
-
Go to Topics.
-
Choose the desired Topic ID.
-
Click View Messages.
-
Select the desired Cloud Pub/Sub subscription.
-
Follow the on-screen instructions.
Pub/sub hook failures
Sometimes, the Pub/sub hook may fail. In the event that the hook fails, we provide a user event type that allows you to look into why the hook failed.
For more details, see User Events.
{
"date": "2024-01-07T09:54:34.183123Z",
"id": "AWUTz0..6KwGSiAAIMN",
"type": "pub_sub_event_failure",
"canal": "hook",
"failed_hook_project": "webhook_host_unreachable",
"failed_hook_message_key": "NOT_FOUND",
"failed_hook_key": "failing_event",
"failed_hook_user_event_type": "login_matching_password",
"failed_hook_message": "… NOT_FOUND: Resource not found (resource=blah1234).",
"failed_hook_topic": "blah1234"
}
Field | Description |
---|---|
The date on which the event occurred. |
|
User event id. |
|
User event type. |
|
The channel through which the event was triggered. |
|
The unique webhook key. |
|
The user event for which the webhook was triggered. |
|
The topic ID of the pub/sub hook that failed. |
|
The error message key.
For example, |
|
The error message for the failed hook. This describes why it failed. For example, the topic ID may have not been found for pub/sub hooks or there is a duplicated external ID. example
|
|
The project name of the pub/sub hook that failed. |
Important terms
- Topic
-
A named resource to which messages are sent by publishers.
- Subscription
-
A named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application.
- Message
-
The combination of data and (optional) attributes that a publisher sends to a topic and is eventually delivered to subscribers.
- Message attribute
-
A key-value pair that a publisher can define for a message.
Resource: Google Cloud Pub/Sub Core Concepts