Open shwetatyagi22 opened 2 years ago
Hi @shwetatyagi22 ,
If you're using this with Laravel, the Consumer class can be injected to your controller function as it's registered as a provider. This should be equally injectable in a command.
use App\Http\Controllers\Controller;
use Bschmitt\Amqp\Consumer;
use Bschmitt\Amqp\Amqp;
use Illuminate\Http\Request;
class MyCoolController extends Controller {
public function myCoolEntryPoint(Request $request, Amqp $consumer) {
$consumer->consume('myfancyqueue', function (AMQPMessage $message, Consumer $resolver) {
$this->doStuffToMyMessage($message);
$resolver->acknowledge($message); //ack message
$resolver->stopWhenProcessed();
});
}
}
I am using below function to consume messages from rabbitmq queue. My IDE is giving me a warning for consume method Non-static method 'consume' should not be called statically