Configure cronjob or Batch Processing for CHT Outbound

Hi @Job_Isabai,

Are you able to post more logs? It’s hard to tell if there is a failure in the logs you have posted.

Here are the logs for a different report.

Thanks for sharing the logs. It seems like the document being checked does not have any changes warranting the transition.

I have the configuration below added to the default config and it works for me. Do you mind trying the same?

To do that you can add the code below to the app_settings.json file after the transitions object and then using cht-conf to load the config to your CHT instance

"outbound": {
    "Regular config": {
      "relevant_to": "doc.type === 'data_record'",
      "destination": {
        "base_url": "https://outboundpush.free.beeceptor.com",
        "path": "/regular"
      },
      "mapping": {
        "id": "doc._id"
      }
    },
    "Cron config": {
      "relevant_to": "doc.type === 'data_record'",
      "destination": {
        "base_url": "https://outboundpush.free.beeceptor.com",
        "path": "/cron"
      },
      "mapping": {
        "id": "doc._id"
      },
      "cron": "*/15 * * * *"
    }
  }

Hi Njuguna,
I have tested a similar config, used compile-app-settings upload-app-settings but this time docs are pushed immediately.


My current version:
image

I would like to request for a quick call on this. Let me know you’re availability.
Thanks,
Job

We tested this on a call today and the feature worked as expected. I think what happened before is that the cron ran right after form submission giving the impression that the outbound push request happened immediately.

3 Likes

Yes I confirm that we tested this feature and I have been trying it out since then. After numerous tests, I have discovered that the cron property is not stable for instance:

When cron time is met, records created during that period (Few minutes before and after) are pushed. However, any records created long before or after the scheduled time are not pushed and this is what is logged onto sentinel:

wWNSkgKQTLKHG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2ND Ur0KMXABxMD9EAM5pSEuTE4xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIAomOjeA
2024-03-06T11:54:29.677 DEBUG: finished transition mark_for_outbound doc task~org.couchdb.user:clinician01~cdc2bb7 2-9914-42c8-a712-2b678ed163aa~ped_benchmark_label_form_pause~ped_benchmark_label_form_pause~1709726047691 is uncha nged seq 23865-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNblAsXYU5NTElOME7HpwWNSkgKQTLK HG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDUr0KMXABxMD9E AM5pSEuTE4xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIAomOjeA
2024-03-06T11:54:29.677 DEBUG: transition results: [false]
2024-03-06T11:54:29.677 DEBUG: nothing changed skipping saveDoc for doc task~org.couchdb.user:clinician01~cdc2bb72 -9914-42c8-a712-2b678ed163aa~ped_benchmark_label_form_pause~ped_benchmark_label_form_pause~1709726047691 seq 23865 -g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNblAsXYU5NTElOME7HpwWNSkgKQTLKHG8ZzBWxYWqK5u alBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDUr0KMXABxMD9EAM5pSEuTE4xsTA 3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIAomOjeA
2024-03-06T11:54:29.729 DEBUG: change event on doc 324a8810-7205-41e0-8080-e018d59ee32c seq 23866-g1AAAAJ7eJzLYWBg 4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNbnAsXYU5NTElOME7HpwWNSkgKQTLKHG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr 0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDUr0KMXABxMD9EAM5pSEuTE4xsTA3IcvAAxAD70Nj9g_Y QANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIApLCjeQ
2024-03-06T11:54:29.912 DEBUG: isRevSame tested false on transition mark_for_outbound for doc 324a8810-7205-41e0-8 080-e018d59ee32c seq 23866-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNbnAsXYU5NTElOME7H pwWNSkgKQTLKHG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDU r0KMXABxMD9EAM5pSEuTE4xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIApLCjeQ
2024-03-06T11:54:29.912 DEBUG: calling transition.onMatch for doc 324a8810-7205-41e0-8080-e018d59ee32c and transit ion mark_for_outbound seq 23866-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNbnAsXYU5NTEl OME7HpwWNSkgKQTLKHG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRj S2NDUr0KMXABxMD9EAM5pSEuTE4xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIApLCjeQ
2024-03-06T11:54:29.940 INFO: Creating outbound task task:outbound:324a8810-7205-41e0-8080-e018d59ee32c
2024-03-06T11:54:29.990 DEBUG: finished transition mark_for_outbound doc 324a8810-7205-41e0-8080-e018d59ee32c is u nchanged seq 23866-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNbnAsXYU5NTElOME7HpwWNSkgK QTLKHG8ZzBWxYWqK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDUr0KMXABx MD9EAM5pSEuTE4xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIApLCjeQ
2024-03-06T11:54:29.990 DEBUG: transition results: [false]
2024-03-06T11:54:29.990 DEBUG: nothing changed skipping saveDoc for doc 324a8810-7205-41e0-8080-e018d59ee32c seq 2 3866-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____szKYkxgYuNbnAsXYU5NTElOME7HpwWNSkgKQTLKHG8ZzBWxYW qK5ualBKqmGOYAMi4cbxr0ZbJhpYnJakrE5qYYlgAyrRxhmBTEsydDUJJVUw_JYgCRDA5ACmjcfYiCvKdhAkyRjS2NDUr0KMXABxMD9EAM5pSEuTE4 xsTA3IcvAAxAD70Nj9g_YQANjA-NkEyOyDHwAMRAahrx1UAONzc3NU7BpzQIApLCjeQ
2024-03-06T11:54:30.235 DEBUG: transitions: queue drained
2024-03-06T11:54:35.633 DEBUG: Initiating all tasks
2024-03-06T11:54:35.633 INFO: Task dueTasks started
2024-03-06T11:54:35.635 INFO: Task reminders started
2024-03-06T11:54:35.635 INFO: Task replications started
2024-03-06T11:54:35.635 INFO: Task outbound started
2024-03-06T11:54:35.636 INFO: Task purging started
2024-03-06T11:54:35.636 INFO: Task transitionsDisabledReminder started
2024-03-06T11:54:35.636 INFO: Task backgroundCleanup started
2024-03-06T11:54:35.636 INFO: Task reminders completed
2024-03-06T11:54:35.636 INFO: Task replications completed
2024-03-06T11:54:35.637 INFO: Task purging completed
2024-03-06T11:54:35.637 INFO: Task transitionsDisabledReminder completed
2024-03-06T11:54:35.670 INFO: Task dueTasks completed
2024-03-06T11:54:35.698 INFO: Background cleanup batch: 23857 → 23866 (7)
2024-03-06T11:54:35.764 INFO: Task backgroundCleanup completed
2024-03-06T11:54:35.779 WARN: Unable to push 042eef38-d61a-43ec-99e0-fdf49b470c57 for ped_benchmark_outbound becau se this outbound config no longer exists, clearing task
2024-03-06T11:54:35.806 WARN: Unable to push 324a8810-7205-41e0-8080-e018d59ee32c for ped_benchmark_outbound becau se this outbound config no longer exists, clearing task
2024-03-06T11:54:35.897 INFO: Task outbound completed

Hello @Job_Isabai,

Thanks for pointing that out. I am looking into this and I will respond here with updates.

Hi @Job_Isabai, after some testing I have finally managed to get the same error you provided. I did this by changing the config and renaming my outbound configuration before the outbound push was scheduled to be sent. Is that the same similar to what you did before getting the error?

Hi @njuguna ,
I did not change my outbound config, everything remained the same, but the error popped up.
thanks,
Job

Hi @Job_Isabai, are you bale to consistently reproduce the error? If so, can you please provide reproduction steps? Please include your outbound push configuration and the time interval and frequency with which you produce documents that match the configuration.

Hello Njuguna here are the steps:

  1. Configure outbound as seen below:
    Cronjob is meant to run after every 30th minute.

  2. Create records and trigger outbound at minute 11 all the way to 20
    You will notice that your records will be saved and not pushed, see the above logs. An outbound task will be generated.

  3. Within the same timeframe you will see a message
    Unable to push ***** for ped_benchmark_outbound because this outbound config no longer exists, clearing task
    After some research, I have realized that your tests are working because you have configured 15th minute cron, with this, the cycle is shorted and CHT send records within 10 minutes before cron-time and 10 minutes after cron-time. This means that records have less waiting time. In your test, try +30minites cron and let me know how it behaves.

1 Like

Hello Job,

I was able to reproduce the same error you are getting. The linked issue is what we will use to track the bug fix.

How many different configurations with cron do you envision using? I want to make sure we test your particular use case as well.

Hi Njuguna,
Thank you very much for this.
I have 3 eCDSS with more than 6 data destinations, but for a start I have 6 different configs. But this number will increase with time. Is there a possibility to consider sending all data-records in batches on a single payload.
Thanks,
Job

Hi Job,

There currently isn’t but I have created an issue to discuss and keep track of that. Feel free to comment and add additional context on the specific use case you have in mind and the benefits you foresee with batch processing.