Let Celery client manage the connection
Closed this issue · 2 comments
crabhi commented
It makes it easier to handle connection failures. The client creation now depends on an established connection. The client should be created at any time but the task submission will fail if it can't connect to the queue.
Example:
client = new Celery('amqp://guest:guest@somerabbit//', 'rpc://guest:guest@somerabbit//', 'celery');
// The server somerabbit doesn't run yet.
client.submit(...); // throws IOException
// Now, the server already started
client.submit(...); // succeeds without any other action taken
crabhi commented
The idea is to have a cached connection that we try to create when we create the application. If it fails, log the message and start a background thread that will try it in loop with some backoff.
When a task is submitted and the connection isn't created yet, try to create it before sending.