Problem/Motivation

The commerce_alexanders module creates API requests and if it is broken for whatever reason that's it. There is no retry or anything. See \commerce_alexanders_commerce_order_update(). It does:

    $alexanders_order = AlexandersOrder::create([
      'order_number' => $order->id(),
      'rush' => $order->hasField('alxdr_rush') && $order->get('alxdr_rush')->value,
      'standardPrintItems' => $alexanders_order_items,
      'shipping' => $alexanders_shipment,
    ]);
    $alexanders_order->save();
    $api = new AlexandersApi();
    $api->createOrder($alexanders_order);

And createOrder() does

    $orderData = $this->buildOrderData($order);
    $url = $this->generateUrl()->toString();
    try {
      $response = $this->client->post($url, $orderData);
    }
    catch (RequestException $e) {
      watchdog_exception('alexanders', $e);
      return FALSE;
    }
    return $this->processResponse($response);

So the good news is that we've logged the fail but there's no retry. Also if the Alexanders API starts to timeout this will make order updates vulnerable to PHP timeouts.

Proposed resolution

In general it is best to queue such API requests rather do them inline. Discuss the best solution.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#4 3063011-4.patch9.49 KBalexpott
#3 3063011-3.patch9.52 KBalexpott

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Title: Expect Alexanders API to fail » Expect Alexanders API to fail or be slow sometimes
alexpott’s picture

Status: Active » Needs review
StatusFileSize
new9.52 KB

Here's a completely untested patch that integrates with the advancedqueue module which provides:

  • Retries out-of-the box
  • A views based UI
  • A nice API
alexpott’s picture

StatusFileSize
new9.49 KB

Rebased on 8.x-1.x now that #3065692: Unnecessary PHP 7.1 code has landed.

joshmiller’s picture

Status: Needs review » Closed (won't fix)

I'm no longer maintaining this module and am marking the project unsupported, so I'm closing its open issues. If you depend on it and want to take over maintenance, say so on the project page and I'll help hand it over.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.