When using the Mailchimp API, we occasionally encounter temporary blocks at the firewall (Akamai).
In some cases, our server’s IP gets blocked for up to 72 hours, which causes the contrib module’s queue processor to repeatedly fail and potentially lose updates.
(Reference: issue #3441822)
To prevent this situation, we implemented a small safeguard in our own integration: we call the Mailchimp /ping endpoint before processing any queue items.
The /ping endpoint is not included in the ThinkShout Mailchimp SDK, so our implementation uses a direct Guzzle request, e.g.:
$client = \Drupal::httpClient();
$response = $client->request('GET', 'https://' . $dc . '.api.mailchimp.com/3.0/ping', [
'auth' => ['anystring', $api_key],
'timeout' => 10,
]);API reference: https://mailchimp.com/developer/marketing/api/ping/
If the ping endpoint is not reachable (timeout, firewall block, 5xx, etc.), we stop the queue processor early so no items are consumed while Mailchimp is unavailable.
Proposed feature
Add an optional “ping before processing” feature inside the contrib module’s queue processor.
Logic
- Before processing queue items, the processor sends a request to /ping.
- If the ping returns an error (e.g., blocked IP, DNS failure, timeout): exit the queue processing without consuming items.
- If the ping succeeds: process queue items normally.
Benefits
- Prevents data loss when Mailchimp is temporarily unreachable.
- Avoids repeatedly consuming and re-queuing items during outages.
- Protects against edge cases such as IP-based rate limiting and CDN firewall blocks.
- Keeps the queue stable without requiring custom patches or overriding the queue processor.
Additional notes
Our implementation is lightweight and cached (to avoid hitting /ping too often).
Issue fork mailchimp-3558897
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xenophyle commentedWould you mind creating an MR or patch to use as a starting point?
Comment #3
kiwad commentedWe did most of this in a custom module except for the ClientFactory.php
We patched this to be able to have a custom proxy specific for mailchimp without having to make it sitewide.
In a custom module, we did something like this :
I've tried to retrieve the specific code for this from our custom module and make it generic
This pattern would be a clean addition directly to the contrib Processor:
Comment #8
xenophyle commentedComment #11
chrisla commentedJust a heads-up that this caused my cron jobs to fail when updating as I didn't grab the updated Mailchimp library when updating the module. It's perhaps worth it to flag this in the release notes