Giter Site home page Giter Site logo

rabbitmq-cli-consumer's Introduction

RabbitMQ cli consumer

Deprecated

All good things come to an end. As of January 1st 2018, this library won't be updated anymore. The APT repository and the library in its current form will be kept online.

There is also good news: there is an official fork maintained by Christian Häusler which I support. All users are encouraged to use his fork instead.

If you are a fellow PHP developer just like me you're probably aware of the following fact: PHP really SUCKS in long running tasks.

When using RabbitMQ with pure PHP consumers you have to deal with stability issues. Probably you are killing your consumers regularly just like me. And try to solve the problem with supervisord. Which also means on every deploy you have to restart your consumers. A little bit dramatic if you ask me.

This library aims at PHP developers solving the above described problem with RabbitMQ. Why don't let the polling over to a language as Go which is much better suited to run long running tasks.

Installation

You have the choice to either compile yourself or by installing via package or binary.

APT Package

As I'm a Debian user myself Debian-based peeps are lucky and can use my APT repository.

Add this line to your /etc/apt/sources.list file:

deb http://apt.vandenbrand.org/debian testing main

Fetch and install GPG key:

$ wget http://apt.vandenbrand.org/apt.vandenbrand.org.gpg.key
$ sudo apt-key add apt.vandenbrand.org.gpg.key

Update and install:

$ sudo apt-get update
$ sudo apt-get install rabbitmq-cli-consumer

Create .deb package for service install

sudo apt-get install golang gccgo-go ruby -y
# Ubuntu
sudo apt-get install gccgo-go -y
# Debian
sudo apt-get install gccgo -y
sudo gem install fpm
./build_service_deb.sh

Binary

Binaries can be found at: https://github.com/ricbra/rabbitmq-cli-consumer/releases

Compiling

This section assumes you're familiar with the Go language.

Use go get to get the source local:

$ go get github.com/ricbra/rabbitmq-cli-consumer

Change to the directory, e.g.:

$ cd $GOPATH/src/github.com/ricbra/rabbitmq-cli-consumer

Get the dependencies:

$ go get ./...

Then build and/or install:

$ go build
$ go install

Usage

Run without arguments or with --help switch to show the helptext:

$ rabbitmq-cli-consumer
NAME:
   rabbitmq-cli-consumer - Consume RabbitMQ easily to any cli program

USAGE:
   rabbitmq-cli-consumer [global options] command [command options] [arguments...]

VERSION:
   0.0.1

AUTHOR:
  Richard van den Brand - <[email protected]>

COMMANDS:
   help, h	Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --executable, -e 	Location of executable
   --configuration, -c 	Location of configuration file
   --verbose, -V	Enable verbose mode (logs to stdout and stderr)
   --include, -i	Include metadata. Passes message as JSON data including headers, properties and message body.
   --help, -h		show help
   --version, -v	print the version

Configuration

A configuration file is required. Example:

[rabbitmq]
host = localhost
username = username-of-rabbitmq-user
password = secret
vhost=/your-vhost
port=5672
queue=name-of-queue
compression=Off

[logs]
error = /location/to/error.log
info = /location/to/info.log

When you've created the configuration you can start the consumer like this:

$ rabbitmq-cli-consumer -e "/path/to/your/app argument --flag" -c /path/to/your/configuration.conf -V

Run without -V to get rid of the output:

$ rabbitmq-cli-consumer -e "/path/to/your/app argument --flag" -c /path/to/your/configuration.conf

Prefetch count

It's possible to configure the prefetch count and if you want set it as global. Add the following section to your configuration to confol these values:

[prefetch]
count=3
global=Off

Configuring the exchange

It's also possible to configure the exchange and its options. When left out in the configuration file, the default exchange will be used. To configure the exchange add the following to your configuration file:

[exchange]
name=mail
autodelete=Off
type=direct
durable=On

How to configure an empty string value

In Go the zero value for a string is "". So, any values not configured in the config file will result in a empty string. Now imagine you want to define an empty name for one of the configuration settings. Yes, we now cannot determine whether this value was empty on purpose or just left out. If you want to configure an empty string you have to be explicit by using the value <empty>.

The executable

Your executable receives the message as the last argument. So consider the following:

$ rabbitmq-cli-consumer -e "/home/vagrant/current/app/command.php" -c example.conf -V

The command.php file should look like this:

#!/usr/bin/env php
<?php
// This contains first argument
$message = $argv[1];

// Decode to get original value
$original = base64_decode($message);

// Start processing
if (do_heavy_lifting($original)) {
    // All well, then return 0
    exit(0);
}

// Let rabbitmq-cli-consumer know someting went wrong, message will be requeued.
exit(1);

Or a Symfony2 example:

$ rabbitmq-cli-consumer -e "/path/to/symfony/app/console event:processing -e=prod" -c example.conf -V

Command looks like this:

<?php

namespace Vendor\EventBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->addArgument('event', InputArgument::REQUIRED)
            ->setName('event:processing')
        ;

    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $message = base64_decode($input->getArgument('event'));

        $this->getContainer()->get('mailer')->send($message);

        exit(0);
    }
}

Compression

Depending on what you're passing around on the queue, it may be wise to enable compression support. If you don't you may encouter the infamous "Argument list too long" error.

When compression is enabled, the message gets compressed with zlib maximum compression before it's base64 encoded. We have to pay a performance penalty for this. If you are serializing large php objects I suggest to turn it on. Better safe then sorry.

In your config:

[rabbitmq]
host = localhost
username = username-of-rabbitmq-user
password = secret
vhost=/your-vhost
port=5672
queue=name-of-queue
compression=On

[logs]
error = /location/to/error.log
info = /location/to/info.log

And in your php app:

#!/usr/bin/env php
<?php
// This contains first argument
$message = $argv[1];

// Decode to get compressed value
$original = base64_decode($message);

// Uncompresss
if (! $original = gzuncompress($original)) {
    // Probably wanna throw some exception here
    exit(1);
}

// Start processing
if (do_heavy_lifting($original)) {
    // All well, then return 0
    exit(0);
}

// Let rabbitmq-cli-consumer know someting went wrong, message will be requeued.
exit(1);

Including properties and message headers

If you need to access message headers or properties, call the command with the --include, -i option set.

$ rabbitmq-cli-consumer -e "/home/vagrant/current/app/command.php" -c example.conf -i

The script then will receive a json encoded data structure which looks like the following.

{
  "properties": {
    "application_headers": {
      "name": "value"
    },
    "content_type": "",
    "content_encoding": "",
    "delivery_mode": 1,
    "priority": 0,
    "correlation_id": "",
    "reply_to": "",
    "expiration": "",
    "message_id": "",
    "timestamp": "0001-01-01T00:00:00Z",
    "type": "",
    "user_id": "",
    "app_id": ""
  },
  "delivery_info": {
    "message_count": 0,
    "consumer_tag": "ctag-./rabbitmq-cli-consumer-1",
    "delivery_tag": 2,
    "redelivered": true,
    "exchange": "example",
    "routing_key": ""
  },
  "body": ""
}

Change your script acording to the following example.

#!/usr/bin/env php
<?php
// This contains first argument
$input = $argv[1];

// Decode to get original value also decrompress acording to your configuration.
$data = json_decode(base64_decode($input));

// Start processing
if (do_heavy_lifting($data->body, $data->properties)) {
    // All well, then return 0
    exit(0);
}

// Let rabbitmq-cli-consumer know someting went wrong, message will be requeued.
exit(1);

If you are using symfonies RabbitMQ bundle (oldsound/rabbitmq-bundle) you can wrap the consumer with the following symfony command.

<?php

namespace Vendor\EventBundle\Command;

use PhpAmqpLib\Message\AMQPMessage;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->addArgument('event', InputArgument::REQUIRED)
            ->setName('event:processing')
        ;

    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $data = json_decode(base64_decode($input->getArgument('event')), true);
        $message = new AMQPMessage($data['body'], $data['properties']);

        /** @var \PhpAmqpLib\Message\AMQPMessage\ConsumerInterface $consumer */
        $consumer = $this->getContainer()->get('consumer');

        if (false == $consumer->execute($message)) {
            exit(1);
        }
    }
}

Strict exit code processing

By default, any non-zero exit code will make consumer send a negative acknowledgement and re-queue message back to the queue, in some cases it may cause your consumer to fall into an infinite loop as re-queued message will be getting back to consumer and it probably will fail again.

It's possible to get better control over message acknowledgement by setting up strict exit code processing. In this mode consumer will acknowledge messages only if executable process return an allowed exit code.

Allowed exit codes

Exit Code Action
0 Acknowledgement
3 Reject
4 Reject and re-queue
5 Negative acknowledgement
6 Negative acknowledgement and re-queue

All other exit codes will cause consumer to fail.

Run consumer with --strict-exit-code option to enable strict exit code processing:

$ rabbitmq-cli-consumer -e "/path/to/your/app argument --flag" -c /path/to/your/configuration.conf --strict-exit-code

Make sure your executable returns correct exit code

#!/usr/bin/env php
<?php
// ...
try {
    if (do_heavy_lifting($data)) {
        // All well, then return 0
        exit(0);
    }
} catch(InvalidMessageBody $e) {
    exit(3); // Message is invalid, just reject and don't try to process again
} catch(TimeoutException $e) {
    exit(4); // Reject and try again
} catch(Exception $e) {
    exit(1); // Unexpected exception will cause consumer to stop consuming
}

Developing

Missing anything? Found a bug? I love to see your PR.

rabbitmq-cli-consumer's People

Contributors

andrefigueira avatar corvus-ch avatar cravler avatar jskarpe avatar louterrailloune avatar ricbra avatar sroze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rabbitmq-cli-consumer's Issues

More logging options (v2.x)

At the moment we can only send logs to files. It would be nice (and necessary for my usecase) to be able to send them anywhere (syslog, logstash, ...).

Is this in the 2.0 roadmap somewhere ? Is this something that might be of interest ? if so, I can try to come up with a pull request.

I was thinking on using Logging. The memory logging it provides would probably allow for more extensive testing without filesystem dependency.

What d'ya think ?

Option to pass additional parameters to consumer e.g. queue name

Hello!

I'm using this for a project that will have many different kinds of workers, and these workers may be used by different clients, so the worker will be the same, but the queue will be different.

I've tried thinking of multiple ways of dealing with the configuration, as I wouldn't want to have 1 config.ini per client/worker as my rabbitmq-cli-consumer will be connecting to the same instance of rabbit so I can see a scenario where I end up with tens of different config.ini per rabbitmq-cli-consumer, where the only difference would be the queue that' it's listening to.

With that In mind, I've thought, what If the consumer could accept additional arguments, for example:

rabbitmq-cli-consumer -e "/my/console my-command" -c /path/to/rabbit.ini -q client-specific-queue-name

Does this sound like something that would be considered if I were to make the amendments and submit a pull request?

Add command line argument option in config file, and add init script

I would like to use rabbitmq-cli-consumer as a service.

Example:

service rabbitmq-cli-consumer start
<read /etc/rabbitmq-cli-consumer.conf>
Execute scripts: "/home/vagrant/current/app/console wb:consumer:mail --env=prod" when receiving queue item (as defined in config).

Ideally, it should work with Upstart as well as Systemd.

keeping it simple: don't declare queues and exchanges

I don't see the point in making the worker declare queues and exchanges. All that should be defined in RMQ config.
If we want to keep the worker simple, then just indicate queue and vhost to subscribe to and leave configuration to RMQ. What d'y'all think ?

Invalid imports on 2.0

On file main.go and config/config.go, the gcfg package needs to be updated to match the correct address, since code.google.com is no longer available.

config/config.go:10:2: cannot find package "code.google.com/p/gcfg" in any of:
/usr/lib/go-1.6/src/code.google.com/p/gcfg (from $GOROOT)
<some_path>/src/code.google.com/p/gcfg (from $GOPATH)
main.go:12:2: cannot find package "gopkg.in/p/gcfg" in any of:
/usr/lib/go-1.6/src/gopkg.in/p/gcfg (from $GOROOT)
/src/gopkg.in/p/gcfg (from $GOPATH)

To get it to work I needed to update both files from "code.google.com/p/gcfg" to gopkg.in/gcfg.v1 after that the build command worked as expected and the binary was generated.

Setting up to autoscale the consumer processes?

Hi there,

I'm currently developing a solution for processing events based on this consumer where I work, however, we may want to scale the amount of workers based on the load, do you have any recommendation on how to achieve this?

Sorry if the wrong place to ask this, just wondering how you went about it?

EDIT: I'm using supervisord to manage the processes, but can only set numprocs as a hard limit

Kind Regards

How to see consumer error?

Hello, sometimes the error appears in appropriate error log file (defined in the config file) but sometimes I can see only below line in error log. How to see what happens?

2015/07/08 14:55:38 Failed: 
2015/07/08 14:55:38 Error: fork/exec app/console: no such file or directory

Setting requeue=false

Hi, I'm consuming my rabbitmq message with this (very useful!) client.
I'm going to implement a Dead Letter Exchanges mechanism as described here. In particular i want to know if is possible to configure the client with the second scenario described:

The message is rejected (basic.reject or basic.nack) with requeue=false,

How can i implements this features?

Thanks in advice
Matteo

Support NACKs without requeing (v2.x)

I see that the handling of custom exit codes from the executed command hasn't been implemented in branch 2.0. Why ?

I'm a heavy user of the NACK with requeue=false option.
Is this something you're thinking of re-implementing in 2.0 version or dropping altogether ?

Pass messages to STDIN

Hi :) Why do you pass messages as console argument and not via STDIN? This would circumvent the problem of limited message sizes and make compression unnecessary.

Routing and RabbitMQBundle consumer usage

Hi! Thanks for this library!
We have a large application built with symfony2 and a pretty big amount of messaging involved. Right now we have more then 20 queues. We exclusively use topic routing.
We are dealing with the problems you are discussing here about long running php commands.

I have two questions:

  • how about assigning the consumer to the correct queue/routing key?

RabbitMQBundle does the magic of defining a yaml configuration file where, for every consumer, you put all the rabbit stuff like:

  • the queue name
  • the routing keys it listen to
  • the callback, which is the service that gets called and stays is up in endless mode.

How do you bypass that with this library?

  • how much effort do you think is needed to adapt this library to call the callback service instead of a custom command?

I'm thinking about a simple command that takes the callback name (maybe from RabbitMQBundle configuration file...) and directly calls the execute function with the encoded message.

Obviously we could transform everything to a command, but it would be a big work, and we eventually lose the yaml configuration file that keeps everything togheter.

Any ideas?

User Configurable Queue Durability Setting

Hi Ric,

I don't know if this has much use, the durability on queue setting is hard coded to true on consumer.go source I tweak config.go and consumer.go to make this user configurable just like what you did on the exchange section, this small change doesn't warrant a pull request afaic, thanks for your client.

--- consumer.go 2015-10-04 06:53:14.955238229 +0800
+++ consumer-mod.go 2015-10-04 06:52:30.962229359 +0800
@@ -101,7 +101,7 @@
infLogger.Println("Succeeded setting QoS.")

infLogger.Printf("Declaring queue \"%s\"...", cfg.RabbitMq.Queue)
  • _, err = ch.QueueDeclare(cfg.RabbitMq.Queue, true, false, false, false, nil)
  • _, err = ch.QueueDeclare(cfg.RabbitMq.Queue, cfg.RabbitMq.Durable, false, false, false, nil)

if nil != err {
return nil, errors.New(fmt.Sprintf("Failed to declare queue: %s", err.Error()))

--- config.go 2015-10-04 06:55:54.460239866 +0800
+++ config-mod.go 2015-10-04 06:55:42.065235967 +0800
@@ -13,6 +13,7 @@
Port string
Vhost string
Queue string

  •   Durable     bool
    Compression bool
    
    }
    Prefetch struct {

how to bind queue and exchange with many routing key

I can add this configuration in php-amqplib/rabbitmq-bundle:

old_sound_rabbit_mq:
    connections:
        consumer_connection:
            host: "%rabbitmq_host%"
            port: "%rabbitmq_port%"
            user: "%rabbitmq_user%"
            password: "%rabbitmq_password%"
    consumers:
        log:
            connection: consumer_connection
            exchange_options:
                name: "exchange_log"
                type: direct
            queue_options:
                name: "log"
                routing_keys:
                    - log
                    - userLog
                    - subscriptionLog

I want to transform this configuration into GO configuration, like this

[rabbitmq]
host = rabbitmq
username = user
password = pass
vhost= /
port= 5672
queue= log
compression= On

[prefetch]
count= 3
global= Off

[exchange]
name=exchange_log
autodelete=Off
type=direct
durable=On

[queuesettings]
routingkey=log

but I can not add only one ropting key.

how to bind queue and exchange with many routing key ?

example:
[queuesettings]
routingkey=[ userLog, subscriptionLog]

When using vhost getting 403

Any vhost that I put in the configuration file other than "/", sample "/test", throws forbidden error:
2017/07/12 16:13:56 Connecting RabbitMQ... 2017/07/12 16:13:56 Failed creating consumer: Failed connecting RabbitMQ: Exception (403) Reason: "no access to this vhost"

Too many arguments

I'm executiing the rabbitmq-cli-consumer as:

/usr/local/bin/rabbitmq-cli-consumer -c /var/www/domain.com/rabbitmq/configuration.conf -e "app/console rabbitmq:consumer -w log_error -e=prod" -V

but receiving error: Too many arguments.

When running as:

php app/console rabbitmq:consumer -w log_error -e=prod &

it works perfectly.

Here's the log:

2015/07/07 11:22:42 Connecting RabbitMQ...
2015/07/07 11:22:42 Connected.
2015/07/07 11:22:42 Opening channel...
2015/07/07 11:22:42 Done.
2015/07/07 11:22:42 Setting QoS... 
2015/07/07 11:22:42 Succeeded setting QoS.
2015/07/07 11:22:42 Declaring queue "tilk_log_error"...
2015/07/07 11:22:42 Registering consumer... 
2015/07/07 11:22:42 Succeeded registering consumer.
2015/07/07 11:22:42 Waiting for messages...
2015/07/07 11:22:44 Processing message...
2015/07/07 11:22:44 Failed. Check error log for details.
2015/07/07 11:22:44 Failed: 


  [RuntimeException]   
  Too many arguments.  



rabbitmq:consumer [-m|--messages[="..."]] [-r|--route[="..."]] [-l|--memory-limit[="..."]] [-d|--debug] [-w|--without-signals] name



2015/07/07 11:22:44 Error: exit status 1
2015/07/07 11:24:37 Processing message...
2015/07/07 11:24:37 Failed. Check error log for details.
2015/07/07 11:24:37 Failed: 


  [RuntimeException]   
  Too many arguments.  

Did I miss something? Thank you

How can I retrieve serialized data from the queue ?

My consumer launched as a command is sucessfully executed but I can not retrieve my serialized data, error for instance, they remain null.

protected function execute(InputInterface $input, OutputInterface $output)
    {
        $message = $input->getArgument('message');

        if (!$message = unserialize(base64_decode($message))) {
            throw new \InvalidArgumentException('Invalid input received');
        }

        $digest = unserialize($message);
        $error = $digest['error'];
        $source = $digest['source'];
...

Any ideas please?

consumer crash

What happens if consumer crashes? Does rabbitMQ will able to buffer the messages until consumer repared? Or all the messages will be processed with error (so badly processed) and thus purged from the queue? Sorry for a stupid question probabely..

Configure durability for queue

This is a great consumer. However, I see that this was added to v2 branch. When is it going to be added to master branch. The ability to set non durable is really necessary and should be configurable.

rabbitmq-cli-consumer with rpc

Hi Richard,
I’m trying to use your rabbitmq-cli-consumer with my symfony 2.3 application; my application uses (oldsound/rabbitmq) rpc, and I’m having some troubles working with your consumer, because my app doesn’t receive any message (I get AMQP timeout error) (maybe because I’ve to set a queue name in rabbitcli conf file, and in rpc configuration in symfony I don’t have a named queue?)

this is the error I get:

2015/03/02 14:45:53 Processing message…
2015/03/02 14:45:54 Failed. Check error log for details.
2015/03/02 14:45:54 Failed:
[RuntimeException]
Too many arguments.
rabbitmq:rpc-server [-m|–messages[=”…”]] [-d|–debug[=”…”]] name
2015/03/02 14:45:54 Error: exit status 1

I’ve tried removing queue name in rabbit cli conf file, now the process is running but no message received/consumed; restoring queue name I get previous error (Too many arguments).

Do you think it's possible to make your client able to work even with rpc?

Thanks a lot.

Matteo

Infinite loop when executable does not exists or can not be executed

Hey,

I have tried to run rabbitmq-cli-consumer with executable which does not have executable mode set, and as soon as first message arrive to the queue my error.log explode.

Current implementation is rejecting message with requeue option set to true if executable return non-zero exit code, which cause message to be redelivered to the same consumer and make it fall into infinite loop. It seems to be a very dangerous behaviour as after deployment executable file could be deleted, or simply will start failing which will cause server to run out of memory quite quickly.

I'm proposing to create a new option --strict-exit-code (or something like this) which will apply stricter logic to exit codes, for example ones mentioned in this comment. Any other exit code will cause rabbitmq-cli-consumer to crash, so if executable does not exist OS will give 255 exit code which will cause consumer to crush with out spamming log file.

As a side effect this change will give more control over message acknowledgment.

Let me know what do you think, if it make sense to you I can make pull request shortly.

Stop consuming messages

Hello there! Is there a way (a signal to send?) to say to the consumer to finish consuming the message and then stop? This would be needed to gracefully update the worker

Thanks!

Scalability

I found this project while i was searching about scalability of RabbitMQ consumers based on que length.

For instance, if there's a certain amount of message is waiting in que, increase the consumer count for that specific que and when the messages are processed decrease the consumer count to previous amount.

I know it's not the feature of the current version but may be in the future?

Supports MessagePack

If the message body encoded by msgpack it would be a raw binary data and cause the message cannot be decoded by msgpack. The solution to solve this issue before the message unserialized, the body field should be normalized as a string rather than casting that type. I was solve this issue by converting the body as a hex representation.

Inconsistent versions

First off, a huge THANKS for this library, and your blog post which lead to this project - It's saved me a ton of time, and discovering all the pitfalls you did myself...!

Now my issue... I installed the version from github on my development (OS X) machine and it says it's version 1.1.0.

I then installed the version on a project staging server (Ubuntu 14.10) using the APT instructions. It also says it's version 1.1.0, however the -i flag seems to be missing from the APT version.

Any chance that you could increment both the version numbers, and the version in the APT repo so that we get the -i goodness through apt-get...?

PHP engine errors cause infinite retries

If the PHP code being called by the consumer exits due to a PHP engine failure -- e.g. memory exhaustion or a compile error) the consumer will simply keep calling the code over and over. The only wait to stop it seems to be killing of supervisord -- removing the entry from the rabbit queue at this point doesn't seem to work.

Make logging optionnal

Hi,

I'm using this project for RabbitMQ consumers, but i have my own logging logic and i don't need to have logs (specially for info level).
So is there a way to make logging optionnal/configurable per level?
Example 1 : Inside the configuration

[logs]
error = true
info = false

OR

[logs]
error = false
info = false

Example 2: By overriding attributes from the command
rabbitmq-cli-consumer -e "/path/to/your/app argument --flag" -c /path/to/your/configuration.conf --log-level=error

rabbitmq-cli-consumer -e "/path/to/your/app argument --flag" -c /path/to/your/configuration.conf --log-level=info

Copy environment variables

If I set environment variables like SYMFONY__RABBITMQ_HOST on my server (or in this case docker container, but whatever), then add a rabbitmq-cli-consumer program to my supervisord config, supervisor is kind enough to copy the environment into the process that runs rabbitmq-cli-consumer, but alas when the consumer runs the symfony command, that environment isn't present, so it fails. I hope that makes sense 😄

Ideally rabbitmq-cli-consumer would copy its environment into the shell running the configured command. Alternatively being able to set environment variables on the command line (or from a config file) would also be ok.

Process stops processing messages after certain amount of time

I'm using your library in combination with Symfony console commands. I set it up, configured it added it to Supervisor and started 2 processes. Everything works fine, but after a few hours (around 3-5) it just stops processing messages from the queue. I then have to restart the processes and then it starts processing messages again. But again, just for few hours.

I looked into log files but its nothing there.
Have you any idea why this could be happening?

My config file:

[rabbitmq]
host = localhost
username = user
password = pass
vhost = /media
queue = media-converter
compression = Off

[exchange]
name = media-converter
type = direct
durable = On

[logs]
error = /home/user/log/rabbitmq-cli-error.log
info = /home/user/log/rabbitmq-cli-info.log

I'm using the v1.1 (apt package) on Ubuntu 14.04.

Per env variables

Hi,

it would be really nice if we could also configure the daemon via flags and/or environment vars, not only by using the config file. We are using docker containers and it's easier to run the daemon this way :-)

For example:

rabbitmq-cli-consumer -h [host] -u [username] -p [password] -P [PORT] -v [vhost] -q [queue]

Consumer Tag

Hi

I would like to consider about use rabbitmq-cli-consumer as my consumer manager because i have RabbitMQ pool that have 200+ consumers on a single server.

But i need to be able to set a Consumer Tag on RabbitMQ when a consumer connects to it.

I just checked /consumer/consumer.go file and saw that on 38. line the consumer tag was passed as empty string like:

msgs, err := c.Channel.Consume(c.Queue, "", false, false, false, false, nil)

If it's possible to put a consumer tag via config or as a parameter would be perfect.

Producer/Consumer same VM on 4G ram

Hi Ric,

I know this is not the right forum to ask this, but i'm going to ask anyway. I spawn 3 consumers I notice that I can only consume 46 message and acknowledge the message at peak. the PHP code that your client is calling is virtually doing nothing, I just confirm the message exit(0); and nothing else in there.

prefetch count was set to 3,5,10,20 and nothing seems to work for me :) I can stress the queue at ease but consuming is really slow.

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.