crabhi / celery-java

Java implementation of Celery client and worker
MIT License
97 stars 29 forks source link

Let Celery client manage the connection #6

Closed crabhi closed 6 years ago

crabhi commented 6 years ago

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 6 years ago

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.

crabhi commented 6 years ago

Fixed in e63def1925641d1531e69f21e4b31cb6a5709dc9