@@ -6,6 +6,7 @@ const AppConfig = require("./src/app_config");
6
6
const ReportProcessingContext = require ( "./src/report_processing_context" ) ;
7
7
const Logger = require ( "./src/logger" ) ;
8
8
const Processor = require ( "./src/processor" ) ;
9
+ const PgBossClient = require ( "./src/pg_boss_client" ) ;
9
10
10
11
/**
11
12
* Gets an array of JSON report objects from the application confing, then runs
@@ -127,7 +128,6 @@ async function runQueuePublish(options = {}) {
127
128
connection : appConfig . postgres ,
128
129
} ) ;
129
130
const queueClient = await _initQueueClient ( knexInstance , appLogger ) ;
130
- const queue = "analytics-reporter-job-queue" ;
131
131
132
132
for ( const agency of agencies ) {
133
133
for ( const reportConfig of reportConfigs ) {
@@ -139,7 +139,7 @@ async function runQueuePublish(options = {}) {
139
139
} ) ;
140
140
try {
141
141
let jobId = await queueClient . send (
142
- queue ,
142
+ appConfig . messageQueueName ,
143
143
_createQueueMessage (
144
144
options ,
145
145
agency ,
@@ -156,13 +156,17 @@ async function runQueuePublish(options = {}) {
156
156
) ;
157
157
if ( jobId ) {
158
158
reportLogger . info (
159
- `Created job in queue: ${ queue } with job ID: ${ jobId } ` ,
159
+ `Created job in queue: ${ appConfig . messageQueueName } with job ID: ${ jobId } ` ,
160
160
) ;
161
161
} else {
162
- reportLogger . info ( `Found a duplicate job in queue: ${ queue } ` ) ;
162
+ reportLogger . info (
163
+ `Found a duplicate job in queue: ${ appConfig . messageQueueName } ` ,
164
+ ) ;
163
165
}
164
166
} catch ( e ) {
165
- reportLogger . error ( `Error sending to queue: ${ queue } ` ) ;
167
+ reportLogger . error (
168
+ `Error sending to queue: ${ appConfig . messageQueueName } ` ,
169
+ ) ;
166
170
reportLogger . error ( util . inspect ( e ) ) ;
167
171
}
168
172
}
@@ -199,7 +203,7 @@ function _initAgencies(agencies_file) {
199
203
async function _initQueueClient ( knexInstance , logger ) {
200
204
let queueClient ;
201
205
try {
202
- queueClient = new PgBoss ( { db : knexInstance . client . acquireConnection ( ) } ) ;
206
+ queueClient = new PgBoss ( { db : new PgBossClient ( knexInstance ) } ) ;
203
207
await queueClient . start ( ) ;
204
208
logger . debug ( "Starting queue client" ) ;
205
209
} catch ( e ) {
@@ -242,7 +246,6 @@ async function runQueueConsume() {
242
246
connection : appConfig . postgres ,
243
247
} ) ;
244
248
const queueClient = await _initQueueClient ( knexInstance , appLogger ) ;
245
- const queue = "analytics-reporter-job-queue" ;
246
249
247
250
try {
248
251
const context = new ReportProcessingContext ( new AsyncLocalStorage ( ) ) ;
@@ -253,7 +256,7 @@ async function runQueueConsume() {
253
256
) ;
254
257
255
258
await queueClient . work (
256
- queue ,
259
+ appConfig . messageQueueName ,
257
260
{ newJobCheckIntervalSeconds : 1 } ,
258
261
async ( message ) => {
259
262
appLogger . info ( "Queue message received" ) ;
0 commit comments