Skip to content

Inability to change the collection name in the transport in php-enque/mongodb transport using array as suggested by docs. #1027

Closed

Description

@josefsabl

Looking at the: \Enqueue\Mongodb\MongodbConnectionFactory::__construct I was unable to figure out how to customize the name of collection for the queue to be stored in and the documentation is wrong here.

Sending something like this doesn't work although stated by documentation as possible as it gets thrown away by the this line $config = $this->parseDsn(empty($config['dsn']) ? 'mongodb:' : $config['dsn']);.

[
    'dsn' => 'mongodb:',
    'dbname' => 'myProject',
    'collection_name' => '_queue',
];

Activity

  1. changed the title [-]Inability to change the collection name in the transport in php-enque/mongodb transport[/-] [+]Inability to change the collection name in the transport in php-enque/mongodb transport using array as suggested by docs.[/+] on Feb 21, 2020
  2. josefsabl commented on Mar 17, 2020

    @josefsabl
    ContributorAuthor

    The documentation has one more bug that eluded us for some time and fully appeared on the server.

          $config = [
            'dsn' => 'mongodb://127.0.0.1/' - Mongodb connection string. see http://docs.mongodb.org/manual/reference/connection-string/
            'dbname' => 'enqueue',          - database name.
            'collection_name' => 'enqueue'  - collection name
            'polling_interval' => '1000',   - How often query for new messages (milliseconds)
          ]
         
          or
         
          mongodb://127.0.0.1:27017/dbname?polling_interval=1000&enqueue_collection=enqueue
    

    This suggests that dbname in first example is the same thing as dbname in the second example and code indeed tries to work with it like that. This however is not the case.

    The MongoDB documentation states that it is NOT a default db, but rather defaultauthdb meaning that it is the database with credentials. On the localhost servers, we don't have database protected by authentication so it worked just fine. But in the production this adapter fails to authenticate because the dbname does not contain credentials.

    So AFAIK there is no correct way to specify the database to be used. I will try to refactor and fix it along with #1031.

  3. stale commented on Apr 16, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions