bschmitt / laravel-amqp Goto Github PK
View Code? Open in Web Editor NEWAMQP wrapper for Laravel and Lumen to publish and consume messages
License: MIT License
AMQP wrapper for Laravel and Lumen to publish and consume messages
License: MIT License
Hi,
After we update to 2.0.6 the consumer returns an error.
ErrorException : mb_strlen() expects parameter 1 to be string, array given
at /var/www/html/gameservice/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPWriter.php:346
342| * @throws \PhpAmqpLib\Exception\AMQPInvalidArgumentException
343| */
344| public function write_shortstr($s)
345| {
346| $len = mb_strlen($s, 'ASCII');
347| if ($len > 255) {
348| throw new AMQPInvalidArgumentException('String too long');
349| }
350|
Exception trace:
1 mb_strlen([], "ASCII")
/var/www/html/gameservice/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPWriter.php:346
2 PhpAmqpLib\Wire\AMQPWriter::write_shortstr([])
/var/www/html/gameservice/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Helper/Protocol/Protocol091.php:438
This only happened when we update to 2.0.6, but once we rollback to 2.0.3 there's no problem.
The readme says that you can add "bschmitt/laravel-amqp": "1.*"
to your composer file, but this isn't true because no version is tagged. Could you tag a version (maybe 0.1.0
)?
Thanks for this awesome package, we're going to use it a lot.
I believe connections are never closed after publishing, looks like the same is happening when consuming to.
There is a static function shutdown() but that is never called...
Hello guys,
I got a problem, but maybe you know the solution.
If I set up exhange_type = topic in amqp.php(settings), can I send direct message into particular queue, not to topic.
I tried a things like that:
$amqpObj->publish('', json_encode($data), [
'queue' => $queueName
]);
but it binds my queue to the default topic and send message into default topic. So, if I have for example 10 REST api with different queues, all of them will be binded to one topic and all will get messages, which is incorrect.
So, do you have a way - how I can use 2 ways: one function sent message into topic and another one send just directly into one queue(and do not bind queue to the default topic)?
Thanks
Hi,
Thanks for Ur nice work :-)
Laravel Queues have a queue:restart
command, to use after deployed fresh code (usually in composer 'post-install-cmd' event).
How to do with laravel-amqp when listening forever ?
Is there a way to create command like laravel-amqp:restart
?
Thanks & cheers
I’m using this project for producing rabbitmq messages to the rest of the infrastructure it interacts with without any issue.
My question is: how would you consume raw rabbitmq messages indefinitely within Laravel without blocking other normal HTTP requests?
I noticed that the basic description does mention “Consume messages forever” and that is exactly what I'm aiming for, however if I were to do so wouldn't that block all http requests?
Would I use the supervisor for this and if so, how do I ensure that supervisor will run my consumer and not Laravel’s queue? I need for other services (that use a custom formatted message – ie, not Laravel’s message format) to send messages to Laravel.
Any help or pointers you may provide is much appreciated.
I am looking to bind a queue with exchange and routing key while consuming. Do anyone help me out to achieve the above using this (bschmitt/laravel-amqp) library?
I have to do something like below:
$binding_key = 'black';
$channel->queue_bind($queue_name, $exchange_name, $binding_key);
Will the below code works:
$connection = new AMQP();
$channel = $connection->channel();
$channel->queue_bind($queue_name, $exchange_name, $binding_key);
Will be great if anyone suggest me with the working code.
As my time is limited recently and I guess this package is quite helpful for others, I want to ask if there is someone which can help me or take over the ownership?
Laravel 7 has been released, this ticket is about checking the compatibility.
Hi,
First of all, thanks for this amazing library. Second, I would like to know how to configure 2 separate instances?
I kinda know how to do it in the config file but not while using it, you know like when you need to use multiple db instances.
$users = DB::connection('foo')->select(...);
Thanks,
Could you add some description how this library is different from Tail? Thanks
Laravel allows to publish the config file like this. It's cumbersome to copy the file from the repo.
I think, this should be added because publishing config files is de-facto standard for laravel packages.
Hey guys,
Due to the latest updates in the php-amqplib/php-amqplib
(I describe them in more details here) the current way consume
method is implemented causes an infinite loop in case blocking
is set to false
(which it is by default).
https://github.com/bschmitt/laravel-amqp/blob/master/src/Consumer.php#L73
This is due to the fact php-amqplib/php-amqplib
disables timeouts for a non-blocking wait()
(https://github.com/php-amqplib/php-amqplib/pull/642/files#diff-195c265ed9a66166715118df34df6ea3R339) and stops execution instead, leading to another wait
cal, and so on, and so on.
You may probably want to reflect this in the documentation for consume
to set that blocking => true
in config, otherwise it may consume lots of CPU since php-amqplib
2.9.
I am looking to subscribe automatically and display it on the front end once I received.
Is there a way to do such? Can you please guide me to achieve?
Hi Björn,
I've added a reject
method to your consumer class to requeue messages if execution/consumption fails. Not sure of you want it in your lib or not.
/**
* Rejects a message and requeues it if wanted.
*
* @param Message $message
* @param bool $requeue
*/
public function reject($message, $requeue)
{
$message->delivery_info['channel']->basic_reject($message->delivery_info['delivery_tag'], $requeue);
}
Cheers,
Rob
hi
I did not find the usage supporting header mode in the package, may I ask whether the use of header mode is supported and how should I call the example
and
I see someone submitting an RPC call, when can it be used
Sometimes it is needed to run a function on a remote computer and wait for the result.
Goal: Implement a easy integrated Remote Procedure Call (RPC) workflow.
Reference:
https://www.rabbitmq.com/tutorials/tutorial-six-php.html
The context argument should be parameter 12, not 11, for the AMQPStreamConnection, which results in an exception ErrorException: stream_socket_client() expects parameter 6 to be resource, boolean given
.
Looks like it should just be getting the arguments in the correct order.
I am following "https://github.com/bschmitt/laravel-amqp" but I am getting "stream_socket_client(): unable to connect to tcp://localhost:5672 (Connection refused)". And I have configured amqp.php too
Please help me out here.
Could you please add a example to solve this?
(comes frome here)
Hello,
Function getProperty()
from laravel-amqp/src/Context.php
on line 63 returns null when array_key_exists
returns false . I suggest to modify:
return array_key_exists($key, $this->properties) ? $this->properties[$key] : null;
to
return array_key_exists($key, $this->properties) ? $this->properties[$key] : [];
to avoid
array_key_exists() expects parameter 2 to be array, null given in Context.php line 76
Hi,I met some problem when i run "composer require bschmitt/laravel-amqp" in Lumen 5.6, such as following text:
`Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for tightenco/collect (locked at v5.6.24) -> satisfiable by tightenco/collect[v5.6.24].
- bschmitt/laravel-amqp 2.0.0 requires illuminate/support v5.5.28 -> satisfiable by illuminate/support[v5.5.28].
- bschmitt/laravel-amqp 2.0.1 requires illuminate/support v5.5.28 -> satisfiable by illuminate/support[v5.5.28].
- Conclusion: don't install illuminate/support v5.5.28
- Installation request for bschmitt/laravel-amqp ^2.0 -> satisfiable by bschmitt/laravel-amqp[2.0.0, 2.0.1].
Installation failed, reverting ./composer.json to its original content.`
then i found your project require "illuminate/support": "v5.5.28", and Lumen 5.6 require "illuminate/support": "5.6.*",so any suggestion? thanks!
I'm just using this plug-in as a consumer in an Artisan Command of a RabbitMQ queue that is fed elswhere.
Everything reads correctly. At the end I get the following error
PHP Fatal error: Uncaught Error: Call to a member function send_channel_method_frame() on null in /opt/worldeducation/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:116
Stack trace:
#0 /opt/worldeducation/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php(97): PhpAmqpLib\Channel\AbstractChannel->send_method_frame(Array, Object(PhpAmqpLib\Wire\AMQPWriter))
#1 /opt/worldeducation/vendor/bschmitt/laravel-amqp/src/Request.php(145): PhpAmqpLib\Channel\AMQPChannel->close()
#2 [internal function]: Bschmitt\Amqp\Request::shutdown(Object(PhpAmqpLib\Channel\AMQPChannel), Object(PhpAmqpLib\Connection\AMQPSSLConnection))
#3 {main}
thrown in /opt/worldeducation/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php on line 116
My code
public function handle()
{
Amqp::consume('brain_etl', function ($message, $resolver) {
try {
$zohoETL = new ZohoETL();
$zohoETL->payload = $message->body;
$zohoETL->save();
$resolver->acknowledge($message);
$resolver->stopWhenProcessed();
} catch (Exception $exception) {
$this->info('Done processing');
}
});
}
I put in the try/catch to try to eliminate the console display, but that didn't change anything.
Any ideas of how to fix this would be appreciated
The way the code is written, it always tries to declare an exchange. And that requires the configure permissions on the exchange resource from the user part. If the user has just write permissions and just wants to publish to that exchange, it raises an exception of access refused. Something that is not expected.
Php amqplib basic_publish allows users to publish messages to given exchange with just write permissions.
Hello!
Please look at https://github.com/queue-interop/queue-interop project. Using interfaces from it allows us reuse some implementations like enqueue, which supports a lot of transports. You can outsource some code
hai i used lumen 5.8.8 to send message headers properties. and it got error
[2019-06-20 09:07:57] local.ERROR: PhpAmqpLib\Exception\AMQPOutOfRangeException: AMQP-rabbit doesn't define data of type [] in C:\laragon\www\kompas-id-apiwcm\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\AMQPAbstractCollection.php:420
Stack trace:
#0 C:\laragon\www\kompas-id-apiwcm\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\AMQPWriter.php(425): PhpAmqpLib\Wire\AMQPAbstractCollection::getDataTypeForSymbol(NULL)
#1 C:\laragon\www\kompas-id-apiwcm\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\AMQPWriter.php(443): PhpAmqpLib\Wire\AMQPWriter->write_table(Array)
#2 C:\laragon\www\kompas-id-apiwcm\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\GenericContent.php(199): PhpAmqpLib\Wire\AMQPWriter->write_table_object(Array)
#3 C:\laragon\www\kompas-id-apiwcm\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Channel\AMQPChannel.php(1123): PhpAmqpLib\Wire\GenericContent->serialize_properties()
#4 C:\laragon\www\kompas-id-apiwcm\vendor\bschmitt\laravel-amqp\src\Publisher.php(18): PhpAmqpLib\Channel\AMQPChannel->basic_publish(Object(Bschmitt\Amqp\Message), 'amq.headers', 'routing-key')
#5 C:\laragon\www\kompas-id-apiwcm\vendor\bschmitt\laravel-amqp\src\Amqp.php(33): Bschmitt\Amqp\Publisher->publish('routing-key', Object(Bschmitt\Amqp\Message))
#6 C:\laragon\www\kompas-id-apiwcm\vendor\illuminate\support\Facades\Facade.php(237): Bschmitt\Amqp\Amqp->publish('routing-key', Object(Bschmitt\Amqp\Message), Array)
#7 C:\laragon\www\kompas-id-apiwcm\app\Http\Controllers\V1\MembershipController.php(64): Illuminate\Support\Facades\Facade::__callStatic('publish', Array)
#8 [internal function]: App\Http\Controllers\V1\MembershipController->create(Object(Laravel\Lumen\Http\Request))
#9 C:\laragon\www\kompas-id-apiwcm\vendor\illuminate\container\BoundMethod.php(32): call_user_func_array(Array, Array)
#10 C:\laragon\www\kompas-id-apiwcm\vendor\illuminate\container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#11 C:\laragon\www\kompas-id-apiwcm\vendor\illuminate\container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#12 C:\laragon\www\kompas-id-apiwcm\vendor\illuminate\container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#13 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(376): Illuminate\Container\Container->call(Array, Array)
#14 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(342): Laravel\Lumen\Application->callControllerCallable(Array, Array)
#15 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(316): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\V1\MembershipController), 'create', Array)
#16 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(278): Laravel\Lumen\Application->callControllerAction(Array)
#17 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(263): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#18 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array)
#19 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(416): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Laravel\Lumen\Http\Request))
#20 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#21 C:\laragon\www\kompas-id-apiwcm\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL)
#22 C:\laragon\www\kompas-id-apiwcm\public\index.php(28): Laravel\Lumen\Application->run()
#23 {main} {"exception":"[object] (PhpAmqpLib\\Exception\\AMQPOutOfRangeException(code: 0): AMQP-rabbit doesn't define data of type [] at C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\php-amqplib\\php-amqplib\\PhpAmqpLib\\Wire\\AMQPAbstractCollection.php:420)
[stacktrace]
#0 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\php-amqplib\\php-amqplib\\PhpAmqpLib\\Wire\\AMQPWriter.php(425): PhpAmqpLib\\Wire\\AMQPAbstractCollection::getDataTypeForSymbol(NULL)
#1 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\php-amqplib\\php-amqplib\\PhpAmqpLib\\Wire\\AMQPWriter.php(443): PhpAmqpLib\\Wire\\AMQPWriter->write_table(Array)
#2 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\php-amqplib\\php-amqplib\\PhpAmqpLib\\Wire\\GenericContent.php(199): PhpAmqpLib\\Wire\\AMQPWriter->write_table_object(Array)
#3 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\php-amqplib\\php-amqplib\\PhpAmqpLib\\Channel\\AMQPChannel.php(1123): PhpAmqpLib\\Wire\\GenericContent->serialize_properties()
#4 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\bschmitt\\laravel-amqp\\src\\Publisher.php(18): PhpAmqpLib\\Channel\\AMQPChannel->basic_publish(Object(Bschmitt\\Amqp\\Message), 'amq.headers', 'routing-key')
#5 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\bschmitt\\laravel-amqp\\src\\Amqp.php(33): Bschmitt\\Amqp\\Publisher->publish('routing-key', Object(Bschmitt\\Amqp\\Message))
#6 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\illuminate\\support\\Facades\\Facade.php(237): Bschmitt\\Amqp\\Amqp->publish('routing-key', Object(Bschmitt\\Amqp\\Message), Array)
#7 C:\\laragon\\www\\kompas-id-apiwcm\\app\\Http\\Controllers\\V1\\MembershipController.php(64): Illuminate\\Support\\Facades\\Facade::__callStatic('publish', Array)
#8 [internal function]: App\\Http\\Controllers\\V1\\MembershipController->create(Object(Laravel\\Lumen\\Http\\Request))
#9 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\illuminate\\container\\BoundMethod.php(32): call_user_func_array(Array, Array)
#10 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\illuminate\\container\\BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#11 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\illuminate\\container\\BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Laravel\\Lumen\\Application), Array, Object(Closure))
#12 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\illuminate\\container\\Container.php(576): Illuminate\\Container\\BoundMethod::call(Object(Laravel\\Lumen\\Application), Array, Array, NULL)
#13 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(376): Illuminate\\Container\\Container->call(Array, Array)
#14 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(342): Laravel\\Lumen\\Application->callControllerCallable(Array, Array)
#15 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(316): Laravel\\Lumen\\Application->callLumenController(Object(App\\Http\\Controllers\\V1\\MembershipController), 'create', Array)
#16 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(278): Laravel\\Lumen\\Application->callControllerAction(Array)
#17 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(263): Laravel\\Lumen\\Application->callActionOnArrayBasedRoute(Array)
#18 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(165): Laravel\\Lumen\\Application->handleFoundRoute(Array)
#19 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(416): Laravel\\Lumen\\Application->Laravel\\Lumen\\Concerns\\{closure}(Object(Laravel\\Lumen\\Http\\Request))
#20 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(171): Laravel\\Lumen\\Application->sendThroughPipeline(Array, Object(Closure))
#21 C:\\laragon\\www\\kompas-id-apiwcm\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(108): Laravel\\Lumen\\Application->dispatch(NULL)
#22 C:\\laragon\\www\\kompas-id-apiwcm\\public\\index.php(28): Laravel\\Lumen\\Application->run()
#23 {main}
"}
my code is like this
$properties = [
'application_headers' => [
'source'=>'google_play'
],
'content_type' => 'application/json',
'delivery_mode' => 2,
'priority' => 1
];
$message = Amqp::message('messagesss',$properties);
Amqp::publish('routing-key', $message , ['exchange' => 'amq.headers']);
i see that the error because the application_headers cannot accept array so i used the AMQPTables in PhpAmqpLib\Wire\AMQPTable
like this
$header = new AMQPTable();
$header->set('source','google_play');
$properties = [
'application_headers' => $header,
'content_type' => 'application/json',
'delivery_mode' => 2,
'priority' => 1
];
$message = Amqp::message('messagesss',$properties);
Amqp::publish('routing-key', $message , ['exchange' => 'amq.headers']);
is there any support of AMQPTables in the wrapper? if not i will try to do pull request
I am using the "bschmitt / laravel-amqp" 2.0 library and I need to connect to the partner's message broker server. It seems they don't accept any exchange parameters in the connection. But when I modified the "exchange" and "exchange_type" fields in the "config / amqp.php" file, I got the error "Please check your settings, exchange is not defined".
The following image is my fault and configuration section.
My English is not very good, if there are grammatical errors please ignore. Thanks
hello,I had a problem using this package
My question is that I want to use rabbitmq through topic mode. I use the mode of matching routes, but it has no effect. May I ask how I should use it or do you have any examples for reference?
Amqp::publish('fruit.red', 'message2' , [ 'exchange_type' => 'topic', 'exchange' => 'test.topick', ]);
Amqp::consume('red.queue', function ($message, $resolver) { var_dump($message->body); $resolver->acknowledge($message); }, [ 'routing' => '*.red', 'exchange' => 'test.topic', 'exchange_type' => 'topic', 'persistent' => true // required if you want to listen forever ]);
In order to make live easier when new Laravel and Lumen releases come out, we need integration tests. There tests should be integrated to Travis.
https://docs.travis-ci.com/user/database-setup/#RabbitMQ
Feel free to contribute
Consume messages forever
Amqp::consume('queue-name', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
});
This method can't receive MQ server's push any more than a few minutes without receiving the message. What's the problem, please?
Would be useful to add basic_qos call before basic_consume
especially for prefetch_count option
http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos
https://github.com/php-amqplib/php-amqplib/blob/master/demo/basic_qos.php
Its a must if you want to run a multiple consumer scenario and control the batch size distributed to each consumer (right now the default is 1000 messages).
Currently the simple workaround is to extend \Bschmitt\Amqp\Consumer and add basic_qos call before parent::consume(), after that you just overwrite the bind for \Bschmitt\Amqp\Consumer with your own extended class.
A config option would be more elegant
Hi,
Direct username + password connection (localhost with no ssl) does not work after this change in php-amqplib: php-amqplib/php-amqplib@995a6d5#diff-5e5ce4c996a350f5b6329ef3430992f3
This change somehow forces connection to use ssl even with no ssl defined in config/amqp.php. I could not find a decent solution myself. Does anyone have a fix for this?
BR,
-Olli
I am having issue using sharding. I want to achieve having one queue that has 6 consumers but with sharding to achieve that each consumer is on one CPU.
After enabling
rabbitmq-plugins enable rabbitmq_sharding
and setting up config
'exchange' => 'shard.videos',
'exchange_type' => 'x-modulus-hash',
making policy
rabbitmqctl set_policy videos-shard "^shard.videos$" "{""shards-per-node"": 1,""routing-key"": ""fc_analyze""}"
with
\Amqp::publish('fc_analyze', 'this is message');
I get it to wright queue but can not get consumer in that queue using this code
\Amqp::consume('videos', function ($message, $resolver) {
var_dump($message->body);
sleep(20);
$resolver->acknowledge($message);
}, [
'message_limit' => 1,
'exchange' => 'shard.videos',
'exchange_type' => 'x-modulus-hash',
'routing_key' => 'fc-analyze',
]
);
Please help and advice.
Thank you
lumen show ErrorException: Cannot redeclare class App
help me ,thank
how to switch connection
Setting exchange to '' gives the error that the exchange parameter isn't provided in the config.
$channel->basic_publish() in php-amqplib accepts '' as the default exchange though, sending to a queue with the same name as the routing key.
Another issue ( after commenting the empty($this->getProperty('exchange')) check ), is that you always declare an exchange. That is denied for the default exchange. Commenting out the exchange-declare block as well makes me successfully deliver a message to my queue through the default exchange.
Hi,
I am using this package to publish and consume the message using RabbitMQ in a Microservices based application. I am publishing the message in service and trying to consume the same in another service.
The documentation is pretty clear on the code to consume the published message in the queue. However, in the traditional Laravel queue process, we would describe the process to be performed inside the handle() method. And call the php artisan queue:work
command to execute the queue.
But here in the documentation, the code is clear to consume the message but How to consume the message and execute the same with an artisan command is confusing.
where would I write the code below code in Laravel application and listen to it in production server:
Amqp::consume('queue-name', function ($message, $resolver) {
var_dump($message->body);
$resolver->acknowledge($message);
});
The goal is to have integration tests which can be executed with upcoming Laravel and Lumen versions. In best case integrated into travis-ci
When running a persistent consumer, it sometimes happen that the AMQP server goes down or reboots.
Is there any way we can catch this event/exception and handle it ?
[ErrorException]
fwrite(): send of 12 bytes failed with errno=104 Connection reset by peer
PHP Fatal error: Uncaught ErrorException: fwrite(): send of 19 bytes failed with errno=32 Broken pipe in .../php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:281
Stack trace:
#0 [internal function]: PhpAmqpLib\Wire\IO\StreamIO->error_handler(8, 'fwrite(): send ...', '/path/...', 281, Array)
#1 /vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php(281): fwrite(Resource id #285, '\x01\x00\x01\...', 8192)
#2 /vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(327): PhpAmqpLib\Wire\IO\StreamIO->write('\x01\x00\x01\...')
#3 /vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(448): PhpAmqpLib\Connection\AbstractConnection->write('\x01\x00\x01\...')
#4 /vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php on line 281
Consumer right now does not make to much sense for my use case.
When im publishing new things i publish it to routing key.
i would like some API like this
Amqp::listen('routing.key,other.key', callback)
this would generate new queue behind the scenes and consume those routing keys.
with current setup i have to create new queue for every routing key and bind it to that routing key.
Also i needed the RPC so im implementing it.
i have something like this.
$response = Amqp::rpc('routing.key');
and for a rpc listener the consumer/listener could be the same as in publish with a difference where in callback we would call something like $resolver->replay(...
right now i have forked and playing with it to suit my needs but i would like if we can implement something like this here so i dont have to keep a local copy of this i my project.
How can I send message as application/json?
I'm Using Laravel 5.2. and where should I add my login credentials of RabbitMQ?.
stream_socket_client(): unable to connect to tcp://: (Failed to parse address ":")
Cause I worked on a Lumen project, a Laravel service provider is missing currently.
I want create channel and publish message in that how can I do that?
Does this support laravel 5.5?
Hello!
It would be great if exchange and queue declaration could be disabled in setup method, cause if you declared a queue for example with dead letter exchange, you have to define this property in consume method, otherwise rabbit will throw an error because your package is try to define a queue with the same name and another properties.
Another problem is you dont merge the queue_properties key with defaults, so i have to add the defaults manually to the properties to every time in my code.
Anyway i think it's not okay that the code always try to declare queues and exchanges cause it's unnecessary communication every time with the server. It would be great to pass a property to declare these things in setup or not.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.