diff --git a/batch_plugin.module b/batch_plugin.module
index 3a4db70..3873cc1 100644
--- a/batch_plugin.module
+++ b/batch_plugin.module
@@ -1,31 +1,17 @@
 <?php
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\batch_plugin\Hook\BatchPluginHooks;
+
 /**
  * @file
  * File for batch_pugin.module.
  */
-
 /**
  * Implements hook_cron().
  */
-function batch_plugin_cron() {
-  // Get all the CRON batch plugins.
-  /** @var \Drupal\batch_plugin\BatchPluginManager $manager */
-  $manager = \Drupal::service('plugin.manager.batch_plugin');
-  $definitions = $manager->getDefinitionsByType('cron');
-  if (empty($definitions)) {
-    return;
-  }
-
-  // Process each CRON batch plugin.
-  /** @var \Drupal\batch_plugin\ProcessorPluginManager $processor_manager */
-  $processor_manager = \Drupal::service('plugin.manager.batch_plugin_processor');
-  foreach ($definitions as $id => $definition) {
-    /** @var \Drupal\batch_plugin\CronProcessorPluginInterface $cron_processor */
-    $cron_processor = $processor_manager->createInstance('cron');
-    $cron_processor->setQueueId($definition['queue_name']);
-    /** @var \Drupal\batch_plugin\BatchPluginInterface $batch_plugin */
-    $batch_plugin = $manager->createInstance($definition['id'], $definition['configuration'] ?? []);
-    $processor_manager->processBatchPlugin($batch_plugin, $cron_processor);
-  }
+#[LegacyHook]
+function batch_plugin_cron()
+{
+    \Drupal::service(BatchPluginHooks::class)->cron();
 }
diff --git a/batch_plugin.services.yml b/batch_plugin.services.yml
index d0a273d..a2bef60 100644
--- a/batch_plugin.services.yml
+++ b/batch_plugin.services.yml
@@ -16,3 +16,7 @@ services:
   logger.batch_plugin_cron:
     class: Drupal\batch_plugin\Logger\BatchPluginCronLog
     arguments: ['@database']
+
+  Drupal\batch_plugin\Hook\BatchPluginHooks:
+    class: Drupal\batch_plugin\Hook\BatchPluginHooks
+    autowire: true
diff --git a/src/Hook/BatchPluginHooks.php b/src/Hook/BatchPluginHooks.php
new file mode 100644
index 0000000..7f14980
--- /dev/null
+++ b/src/Hook/BatchPluginHooks.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\batch_plugin\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for batch_plugin.
+ */
+class BatchPluginHooks
+{
+    /**
+     * @file
+     * File for batch_pugin.module.
+     */
+    /**
+     * Implements hook_cron().
+     */
+    #[Hook('cron')]
+    public static function cron()
+    {
+        // Get all the CRON batch plugins.
+        /** @var \Drupal\batch_plugin\BatchPluginManager $manager */
+        $manager = \Drupal::service('plugin.manager.batch_plugin');
+        $definitions = $manager->getDefinitionsByType('cron');
+        if (empty($definitions)) {
+            return;
+        }
+        // Process each CRON batch plugin.
+        /** @var \Drupal\batch_plugin\ProcessorPluginManager $processor_manager */
+        $processor_manager = \Drupal::service('plugin.manager.batch_plugin_processor');
+        foreach ($definitions as $id => $definition) {
+            /** @var \Drupal\batch_plugin\CronProcessorPluginInterface $cron_processor */
+            $cron_processor = $processor_manager->createInstance('cron');
+            $cron_processor->setQueueId($definition['queue_name']);
+            /** @var \Drupal\batch_plugin\BatchPluginInterface $batch_plugin */
+            $batch_plugin = $manager->createInstance($definition['id'], $definition['configuration'] ?? [
+            ]);
+            $processor_manager->processBatchPlugin($batch_plugin, $cron_processor);
+        }
+    }
+}
diff --git a/src/Plugin/QueueWorker/BatchPluginQueueWorker.php b/src/Plugin/QueueWorker/BatchPluginQueueWorker.php
index 8f9d6d3..3bcd15f 100644
--- a/src/Plugin/QueueWorker/BatchPluginQueueWorker.php
+++ b/src/Plugin/QueueWorker/BatchPluginQueueWorker.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\batch_plugin\Plugin\QueueWorker;
 
+use function GuzzleHttp\json_decode;
 use Drupal\batch_plugin\PluginCreationTrait;
 use Drupal\batch_plugin\ProcessorPluginManagerInterface;
 use Drupal\Core\Queue\QueueWorkerBase;
@@ -71,7 +72,7 @@ class BatchPluginQueueWorker extends QueueWorkerBase {
         $context = [];
       }
       else {
-        $context = \GuzzleHttp\json_decode($result->context, TRUE);
+        $context = json_decode($result->context, TRUE);
       }
     }
     if (!empty($data['finished_callback'])) {
@@ -79,7 +80,7 @@ class BatchPluginQueueWorker extends QueueWorkerBase {
         $operations = [];
       }
       else {
-        $operations = \GuzzleHttp\json_decode($result->operations, TRUE);
+        $operations = json_decode($result->operations, TRUE);
       }
       $batch_plugin->finished(TRUE, $context['results'] ?? [], $operations);
     }
diff --git a/src/QueueProcessorPluginBase.php b/src/QueueProcessorPluginBase.php
index 368812b..08a048e 100644
--- a/src/QueueProcessorPluginBase.php
+++ b/src/QueueProcessorPluginBase.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\batch_plugin;
 
+use function GuzzleHttp\json_encode;
 use Drupal\batch_plugin\Logger\BatchPluginCronLog;
 
 /**
@@ -168,7 +169,7 @@ abstract class QueueProcessorPluginBase extends ProcessorPluginBase implements Q
     $this->database->insert('batch_plugin_queue_context')
       ->fields([
         'queue_id' => $this->queueId,
-        'operations' => \GuzzleHttp\json_encode($this->operations),
+        'operations' => json_encode($this->operations),
       ])
       ->execute();
   }
