@@ -9,33 +9,25 @@ const PERSISTENT_QUEUE_DB_NAME = 'cds.outbox.Messages'
99async function collectLatestQueueInfo ( queueEntity , serviceName , maxAttempts ) {
1010 const coldEntriesRow = await SELECT . one
1111 . columns ( [ { func : 'count' , args : [ { val : 1 } ] , as : 'cold_count' } ] )
12- . from ( queueEntity )
13- . where ( {
14- target : serviceName ,
15- attempts : { '>=' : maxAttempts }
16- } )
12+ . from ( queueEntity ) . where `target = ${ serviceName } or contains(msg, ${ '"service":"' + serviceName } )` . where ( {
13+ attempts : { '>=' : maxAttempts }
14+ } )
1715
1816 const remaingEntriesInfoRow = await SELECT . one
1917 . columns ( [
2018 { func : 'count' , args : [ { val : 1 } ] , as : 'remaining_count' } ,
2119 { func : 'min' , args : [ { ref : [ 'timestamp' ] } ] , as : 'min_timestamp' } ,
2220 { func : 'max' , args : [ { ref : [ 'timestamp' ] } ] , as : 'max_timestamp' }
2321 ] )
24- . from ( queueEntity )
25- . where ( {
26- target : serviceName ,
27- attempts : { '<' : maxAttempts }
28- } )
22+ . from ( queueEntity ) . where `target = ${ serviceName } or contains(msg, ${ '"service":"' + serviceName } )` . where ( {
23+ attempts : { '<' : maxAttempts }
24+ } )
2925
3026 const remainingEntries = remaingEntriesInfoRow ?. [ 'remaining_count' ] ?? 0
3127
32- const medianStorageTimeRow = await SELECT . one
33- . columns ( [ { ref : [ 'timestamp' ] , as : 'med_timestamp' } ] )
34- . from ( queueEntity )
35- . where ( {
36- target : serviceName ,
37- attempts : { '<' : maxAttempts }
38- } )
28+ const medianStorageTimeRow = await SELECT . one . columns ( [ { ref : [ 'timestamp' ] , as : 'med_timestamp' } ] ) . from ( queueEntity )
29+ . where `target = ${ serviceName } or contains(msg, ${ '"service":"' + serviceName } )`
30+ . where ( { attempts : { '<' : maxAttempts } } )
3931 . orderBy ( { ref : [ 'timestamp' ] , sort : 'asc' } )
4032 . limit ( 1 , Math . floor ( remainingEntries / 2 ) )
4133
0 commit comments