@@ -46,11 +46,11 @@ function processJob(job, done, log, info) {
4646 return Promise . reject ( new Error ( 'Invalid data. Expected data structure is {name: string}' ) ) ;
4747 }
4848 } else {
49- log ( `Consuming: ${ info || 'no extra info provided' } : ${ JSON . stringify ( job . data ) } ` ) ;
49+ log ( `Consuming: ${ info || 'no extra info provided' } : ${ JSON . stringify ( job ) } ` ) ;
5050
5151 if ( done ) {
5252 setTimeout ( ( ) => {
53- writeToAFileToProveThatThisParticularJobHasBeenProcessed ( getJobData ( job ) ) . then ( ( ) => {
53+ writeToAFileToProveThatThisParticularJobHasBeenProcessed ( getJobData ( job ) , log ) . then ( ( ) => {
5454 fetch ( `http://127.0.0.1:${ agentPort } ` )
5555 . then ( ( ) => {
5656 log ( 'The follow up request after receiving a message has happened.' ) ;
@@ -73,7 +73,7 @@ function processJob(job, done, log, info) {
7373 } , 100 ) ;
7474 } else {
7575 return delay ( 100 )
76- . then ( ( ) => writeToAFileToProveThatThisParticularJobHasBeenProcessed ( getJobData ( job ) ) )
76+ . then ( ( ) => writeToAFileToProveThatThisParticularJobHasBeenProcessed ( getJobData ( job ) , log ) )
7777 . then ( ( ) => fetch ( `http://127.0.0.1:${ agentPort } ` ) )
7878 . then ( ( ) => {
7979 log ( 'The follow up request after receiving a message has happened.' ) ;
@@ -155,7 +155,7 @@ function getJobData(job) {
155155 } ;
156156}
157157
158- function writeToAFileToProveThatThisParticularJobHasBeenProcessed ( jobData ) {
158+ function writeToAFileToProveThatThisParticularJobHasBeenProcessed ( jobData , log ) {
159159 let fileCreatedByJob ;
160160
161161 if ( jobData . data . bulkIndex ) {
@@ -186,6 +186,8 @@ function writeToAFileToProveThatThisParticularJobHasBeenProcessed(jobData) {
186186
187187 jobData . pid = process . pid ;
188188
189+ log ( `Writing file ${ fileCreatedByJob } to prove that this job has been processed.` ) ;
190+
189191 return new Promise ( ( resolve , reject ) => {
190192 fs . writeFile ( fileCreatedByJob , JSON . stringify ( jobData , null , 2 ) , ( err , success ) => {
191193 if ( err ) {
0 commit comments