You are here

function sf_notifications_drush_process_queue in Salesforce Suite 7.2

Drush callback to process the Salesforce queue manually.

1 string reference to 'sf_notifications_drush_process_queue'
sf_notifications_drush_command in sf_notifications/sf_notifications.drush.inc
Implements hook_drush_command().

File

sf_notifications/sf_notifications.drush.inc, line 58
drush integration for apachesolr.

Code

function sf_notifications_drush_process_queue() {
  $total = 0;
  $queue = DrupalQueue::get('sf_notifications_queue');
  while ($item = $queue
    ->claimItem(60)) {
    $ret = _sf_notifications_parse_handle_message($item->data);
    if ($ret) {
      salesforce_api_log(SALESFORCE_LOG_SOME, 'Queued notification processed. Contents: <pre>%content</pre>', array(
        '%content' => print_r($item->data, TRUE),
      ));
      drush_print(dt('Queued notification processed. Contents: <pre>%content</pre>', array(
        '%content' => print_r($item->data, TRUE),
      )));
      $queue
        ->deleteItem($item);
      $total++;
    }
    else {
      salesforce_api_log(SALESFORCE_LOG_ALL, 'Queued notification processing failed. Contents: <pre>%content</pre>', array(
        '%content' => print_r($item->data, TRUE),
      ), WATCHDOG_ERROR);
      drush_print(dt('Queued notification processing failed. Contents: <pre>%content</pre>', array(
        '%content' => print_r($item->data, TRUE),
      )));
      $total++;
    }
  }
  drush_print(dt('@total items processed', array(
    '@total' => $total,
  )));
}