Skip to content

Add ability to change used context. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2018

Conversation

makasim
Copy link
Member

@makasim makasim commented Jan 2, 2018

fixes php-enqueue/enqueue-dev#308

To change the context:

# config/packages/enqueue_elastica.yml

enqueue_elastica:
    context: 'your_custom_context_service_id'

@kbsali
Copy link

kbsali commented Jan 3, 2018

Finally got the config to work (it was not easy! :)),
but it does not work!

Here is the setup :

// config.yml
...
enqueue:
    transport:
        default: "redis"
        fs:
            path: /tmp
        redis:
            host: "%snc_redis.dsn%"
            vendor: predis
            persisted: false
            lazy: true
enqueue_elastica:
    context: enqueue.transport.fs.context
// composer.json
...
        "enqueue/elastica-bundle": "dev-add-ability-to-change-queue-context",
        "enqueue/enqueue-bundle": "^0.8",
        "enqueue/fs": "^0.8",
        "enqueue/redis": "^0.8",
...

Then i execute on 1 side :

app/console enqueue:transport:consume enqueue_elastica.populate_processor -vvv 
17:44:45 DEBUG     [event] Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[
  "event" => "console.command",
  "listener" => "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure"
]
[
  "token" => "5a4d087d238d7"
]
17:44:46 DEBUG     [event] Notified event "console.command" to listener "Http\HttplugBundle\Discovery\ConfiguredClientsStrategy::onEvent".
[
  "event" => "console.command",
  "listener" => "Http\HttplugBundle\Discovery\ConfiguredClientsStrategy::onEvent"
]
[
  "token" => "5a4d087d238d7"
]
17:44:46 DEBUG     [event] Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
[
  "event" => "console.command",
  "listener" => "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand"
]
[
  "token" => "5a4d087d238d7"
]
17:44:46 DEBUG     [event] Notified event "console.command" to listener "Ekino\Bundle\NewRelicBundle\Listener\CommandListener::onConsoleCommand".
[
  "event" => "console.command",
  "listener" => "Ekino\Bundle\NewRelicBundle\Listener\CommandListener::onConsoleCommand"
]
[
  "token" => "5a4d087d238d7"
]
[debug] Set context's logger Symfony\Component\Console\Logger\ConsoleLogger
[info] Start consuming

And :

app/console fos:elastica:populate --pager-persister=queue
Resetting ad

But nothing happens until the populate process dies (Overall reply time (180 seconds) has been exceeded.)

Here is the file it creates in /tmp :

$ more /tmp/fos_elastica_populate
                  |{"body":"{\"options\":{\"max_per_page\":100,\"delete\":true,\"reset\":true,\"ignore_errors\":false,\"sleep\":0,\"indexName\":\"ad\",\"typeName\":\"ad\"},\"page\":1}","properties":[],"headers":{"reply_to":"tmp-q-5a4d08eb0d5255.2002870
1"}}                  |{"body":"{\"options\":{\"max_per_page\":100,\"delete\":true,\"reset\":true,\"ignore_errors\":false,\"sleep\":0,\"indexName\":\"ad\",\"typeName\":\"ad\"},\"page\":2}","properties":[],"headers":{"reply_to":"tmp-q-5a4d08eb0d5255.200
28701"}}                  |{"body":"{\"options\":{\"max_per_page\":100,\"delete\":true,\"reset\":true,\"ignore_errors\":false,\"sleep\":0,\"indexName\":\"ad\",\"typeName\":\"ad\"},\"page\":3}","properties":[],"headers":{"reply_to":"tmp-q-5a4d08eb0d5255
...

Any help/hint appreciated!

thanks @makasim !

@makasim
Copy link
Member Author

makasim commented Jan 3, 2018

That's because the consume command is only able to work with the default context. As for now, you have to register another consume command (with a different name) for the desired context.

https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/enqueue-bundle/Resources/config/services.yml#L22

@makasim
Copy link
Member Author

makasim commented Jan 4, 2018

@makasim makasim merged commit e2b7252 into master Jan 4, 2018
@makasim makasim deleted the add-ability-to-change-queue-context branch January 4, 2018 23:08
@kbsali
Copy link

kbsali commented Jan 8, 2018

thanks, although i'm not sure i understand how to tackle this... :)

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

Successfully merging this pull request may close these issues.

Unable to populate Elasticsearch when using 2 different transport queues
2 participants