You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Order Model is in mysql with a belongsTo Relationship.
use Illuminate\Database\Eloquent\Model;
class DeviceOrder extends Model
{
protected $connection = 'mysql';
protected $table = 'device_orders';
public function device()
{
return $this->belongsTo('App\Models\Device', 'device_id');
}
}
Device Model is MongoDB Model (with HybridRelations with Order Model)
use Jenssegers\Mongodb\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\HybridRelations;
class Device extends Model
{
use HybridRelations;
...
}
I have access to Device model via Eloquent Relationships.
for example :
when I create an Event and pass Order Model to it. I have access to Device model via relationships in Event Listener when Event Listener work withoutQueue.
use App\Events\NewOrderSubmitted;
class ProcessOrder # <-----------
{
public function handle(NewOrderSubmitted $event)
{
$order = $event->order;
$device = $order->device; # <-----------
Log::info('Device Info: ' . $device);
}
}
But when I implement ShouldQueue to Listener Class, Queue visible in Horizon but it will timeout after about 300 seconds.
use App\Events\NewOrderSubmitted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class ProcessOrder implements ShouldQueue # <-------
{
public function handle(NewOrderSubmitted $event)
{
$order = $event->order;
$device = $order->device; # <-------
Log::info('Device Info: ' . $device);
}
}
Although it work in Queue mode without Eloquent Relationships and just with ::find() method.
use App\Events\NewOrderSubmitted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class ProcessOrder implements ShouldQueue # <-------
{
public function handle(NewOrderSubmitted $event)
{
$order = $event->order;
$device = Device::find($order->id); # <-------
Log::info('Device Info: ' . $device);
}
}
I do not think it's because of real timeout problems or sothing related with connectTimeoutMS, socketTimeoutMS, wTimeoutMS or maxTimeMS options.
because in ::find() mode it is very fast in just milliseconds.
Hello @mauri870,
yes
I solved the problem just with adding use HybridRelations; to first relational Model too (in my case DeviceOrder class).
Another suggestion is to add Connection name in both mysql and MongoDB Model classes when they have relations together even when on of them have default Connection name, This will cause problem if you do not in some situations.
Problem scenario:
Order
Model is in mysql with abelongsTo
Relationship.Device
Model isMongoDB
Model (withHybridRelations
withOrder
Model)I have access to Device model via Eloquent Relationships.
for example :
when I create an
Event
and passOrder
Model to it. I have access toDevice
model via relationships in EventListener
when Event Listener work withoutQueue
.But when I implement
ShouldQueue
toListener
Class, Queue visible inHorizon
but it will timeout after about 300 seconds.Although it work in
Queue
mode without Eloquent Relationships and just with::find()
method.Timeout Error:
I do not think it's because of real timeout problems or sothing related with
connectTimeoutMS
,socketTimeoutMS
,wTimeoutMS
ormaxTimeMS
options.because in
::find()
mode it is very fast in just milliseconds.Laravel Framework: 5.6.39
jenssegers/mongodb: 3.4.5
Laravel/horizon: v1.4.3
The text was updated successfully, but these errors were encountered: