Laravel5 Iron.mq4 reservation_id

146 Views Asked by At

I'm trying to run a simple queuing system using the above tools.

I am getting the Queue to push messages to my Iron.IO dashboard. So I can see the hashed messages there. But when I run supervisor and php artisan queue:listen, I keep getting the following error.

exception 'IronCore\HttpException' with message 'http error: 400 | {"msg":"A reservation_id is required"}' in /var/www/rmp-connect.co.uk/vendor/iron-io/iron_core/src/IronCore.php:414

I've tried different versions of IronIO but it looks as if 4.* is the recommended version for Laravel 5.1.

My routes have the following:

Route::get('queue/export', array(
    'as' => 'queue/export',
    'uses' => 'ExportController@queueExport'
));

Route::post('queue/receive', array(
    'as' => 'queue/receive',
    'uses' => 'ExportController@receive'

));

The ExportController, in the first Route has the following:

<?php

class ExportController extends Controller
{

/**
 * This will send a new task to iron named “exportCSV”, and will also include the user id, company id,
 * and the file name to write the results to as an array. All of this data will be passed back
 * to our app, when the task is ready to be run.
 */
public function queueExport()
{

    $company_id = rand(1, 100000);

    $user_id = rand(1,1000000);

    $exportName = 'TEST_CSV_'. rand(1,100000);

    $apiClass = 'Export';

    $data = ['user_id' => $user_id, 'exportName' => $exportName, $user_id => 12];

    $job = (new App\Jobs\Export($data))->onQueue('connect');

    $this->dispatch($job);

}

/**
 * The marshal’s job is to direct the response to the proper task to be completed.
 * This is based on the name we provided when we post to a queue.
 * In our case, it is called 'Connect' for now.
 * @return mixed
 */
public function receive()
{
    //We will need to respond to iron when they send us a new export task to be completed.
        return \Queue::marshal();

    }

}

My Export Job Class has the following:

<?php

namespace App\Jobs;

use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;

class Export extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    protected $data;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {

        \Log::info(print_r($this->data, true));

        // Code to export a CSV and email the user some
        // the URL of where they can access the file.
        \Log::info('RUNNING EXPORT CLASS API');



    }
}
0

There are 0 best solutions below