Laravel Microservices- Breaking A Monolith To M... Direct

// app/Listeners/ReduceStockListener.php class ReduceStockListener

Install laravel-opentelemetry :

try $user = JWTAuth::parseToken()->authenticate(); catch (Exception $e) return response()->json(['error' => 'Unauthorized'], 401); // Inject the user ID from token into the request $request->merge(['authenticated_user_id' => $user->id]); Laravel Microservices- Breaking a Monolith to M...

// app/Http/Middleware/JwtMiddleware.php public function handle($request, Closure $next) // app/Listeners/ReduceStockListener

public function handle(OrderPlaced $event) foreach ($event->orderData['items'] as $item) Product::where('id', $item['product_id']) ->decrement('stock', $item['quantity']); catch (Exception $e) return response()-&gt

order-service: build: ./order-service environment: SERVICES_CATALOG_URL: http://catalog-service:8000 RABBITMQ_HOST: rabbitmq ports: - "8003:8000"