title: Laravel queue listener from external service
body: <p>I have a legacy API written in Laravel, and I'm attempting to post data to it from a RabbitMQ queue. I'm using a third party library to integrate RabbitMQ into the native Laravel Queue architecture. Which works well, and is handling messages correctly when the listener console command is running. </p>
  
  <p>However, when I pass the following event, including the job and data keys, which are required by the queue handler... </p>
  
  <pre><code>{"job":"SixtyFiveContrib\\Jobs\\CreateSubmissionMetaDataJob@handle","data":{"title":"","story":"Testing 123","author":"Ewan Valentine","email":"","address":"","dob":"","phone":"","site":"The Lad Bible","legal":"The LAD bible - Facebook","agreed":false,"signature":"","files":[{"filename":"test.png","filesize":0,"filetype":""}],"agreement":{"id":"","facebook_id":""},"attempts":1036}}
  </code></pre>
  
  <p>I notice the class which handles queued events, splits the class path and the method name (SixtyFiveContrib\Jobs\CreateSubmissionMetaDataJob and handle), and attempts to call that class from the container. </p>
  
  <p>However jobs aren't automatically part of the container. When I attempt to add the job into the container myself, I run into a situation where I can't dynamically pass the 'data' from the queue into the job, for example... </p>
  
  <pre><code>$this-&gt;app-&gt;bind(\SixtyFiveContrib\Jobs\CreateSubmissionMetaDataJob::class, function() {
      return \SixtyFiveContrib\Jobs\CreateSubmissionMetaDataJob(????);
  });
  </code></pre>
  
  <p>If I omit this entry from the container, the queue handler can no longer resolve the job, I get the following <strong>error...</strong> </p>
  
  <blockquote>
    <p>[Illuminate\Contracts\Container\BindingResolutionException]<br>
    Unresolvable dependency resolving [Parameter #0 [  $data ]]
    in class SixtyFiveContrib\Jobs\CreateSubmissionMetaDataJob</p>
  </blockquote>
  
  <p>Here's my job class (sensitive business logic omitted). </p>
  
  <pre><code>&lt;?php
  
  namespace SixtyFiveContrib\Jobs;
  
  use App;
  
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Queue\InteractsWithQueue;
  use Illuminate\Contracts\Bus\SelfHandling;
  use Illuminate\Contracts\Queue\ShouldQueue;
  
  use SixtyFiveContrib\Jobs\Job;
  
  /**
   * CreateSubmissionsMetaDataJob
   *
   * @author    Ewan Valentine &lt;ewan@theladbible.com&gt;
   * @copyright The LAD bible Group - 2016
   */
  class CreateSubmissionMetaDataJob extends Job implements SelfHandling 
  {
      use InteractsWithQueue, SerializesModels;
  
      /**
       * @var array $data
       */
      public $data;
  
      /**
       * __construct
       *
       * @param array $this-&gt;data
       */
      public function __construct($data)
      {
          $this-&gt;data = $data;
      }
  
      public function handle() 
      {
          try {
  
              // Omitted 
          } catch (\Exception $e) {
              \Log::error($e-&gt;getMessage() . " " . $e-&gt;getLine());
              return $e-&gt;getMessage(); 
          }
      }
  }
  </code></pre>