Notification Worker - Sage-Bionetworks/BridgeWorkerPlatform GitHub Wiki
This guide assumes you are familiar with Bridge, and that you have already followed or are concurrently following the BridgeWorkerPlatform Getting Started guide.
Configuring the Notifications Worker
Before the Notifications Worker can run, both the Bridge Study and the Notification Worker's DDB tables need to be configured. NotificationTest.java creates a default setup in the api study. If you go that route, you can skip the next two steps.
Bridge
Bridge needs to be configured with a study burst schedule. A few pre-requisites you'll need:
- A list of activity event IDs to represent the start of each study burst. (Enrollment can be used for the first one if the first study burst start date coincides with enrollment.)
- Data groups that are required for users to receive notifications (there must be at least one).
- A task ID representing the burst activity completion task.
An example study fragment you'll need looks like
{
...
"automaticCustomEvents": {
"activityBurst2Start": "P13W",
"activityBurst3Start": "P26W",
"activityBurst4Start": "P39W",
"activityBurst5Start": "P52W",
"activityBurst6Start": "P65W",
"activityBurst7Start": "P78W",
"activityBurst8Start": "P91W",
"activityBurst9Start": "P104W",
...
},
"dataGroups":["notification_group_A", "notification_unsubscribed", ...],
"taskIdentifiers":["study-burst-task", ...],
...
}
You'll also need to create the actual study burst schedule. See for example
{
"label":"Study Burst Schedule",
"strategy":{
"type":"SimpleScheduleStrategy",
"schedule":{
"scheduleType":"RECURRING",
"eventId":"enrollment,custom:activityBurst2Start,custom:activityBurst3Start,custom:activityBurst4Start,custom:activityBurst5Start,custom:activityBurst6Start,custom:activityBurst7Start,custom:activityBurst8Start,custom:activityBurst9Start",
"expires":"P1D",
"interval":"P1D",
"sequencePeriod":"P14D",
"times":["00:00"],
"activities":[
{
"label":"Study Burst Task",
"task":{
"identifier":"study-burst-task"
}
},
...
]
}
}
}
Note that in the schedule, you need to pre-pend activity event IDs (other than "enrollment") with "custom:". For example, the activity event ID is "activityBurst2Start", but the schedule references it as "custom:activityBurst2Start".
Worker
The NotificationConfig table needs to be filled in. See https://sagebionetworks.jira.com/wiki/spaces/BRIDGE/pages/505184257/Notification+Configuration
Testing the Notifications Worker
-
Ensure the Bridge Server (and its dependencies such as Redis and MySQL) and the Worker Platform are both running.
-
In the AWS console, go to Simple Queue Service (SQS), select the queue your Worker Platform reads from, and send the following message:
{ "service":"ActivityNotificationWorker", "body":{ "studyId":"api", "date":"2018-05-05", "tag":"manual test" } }
"studyId" is the study you want to run the notifications worker on. "date" is the date that you want to be processed. "tag" is descriptive text used for logging purposes.