Exemple #1
1
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are those
 * of the authors and should not be interpreted as representing official policies, 
 * either expressed or implied, of the FreeBSD Project. 
 *
 * http://massivescale.net/
 * http://gdr.geekhood.net/
 * gdr@gdr.name
 */
require_once 'celery.php';
$c = new Celery('localhost', 'gdr', 'test', 'wutka', 'celery', 'celery', 5672, 'php-amqplib');
#$result = $c->PostTask('tasks.add', array(2,2));
$result = $c->PostTask('tasks.delayed', array());
#$result = $c->PostTask('tasks.fail', array());
#echo $result;
while (!$result->isReady()) {
    #	sleep(1);
    echo '...';
}
if ($result->isSuccess()) {
    echo $result->getResult();
} else {
    echo "ERROR";
    echo $result->getTraceback();
}
Exemple #2
0
 function __construct($params)
 {
     $exchange = 'celery';
     $binding = 'celery';
     $port = 5672;
     $host = $params['host'];
     $login = $params['login'];
     $password = $params['password'];
     $vhost = $params['vhost'];
     if (!class_exists('AMQPConnection')) {
         throw new CeleryException("Class AMQPConnection not found\nMake sure that AMQP extension is installed and enabled:\nhttp://www.php.net/manual/en/amqp.installation.php");
     }
     foreach (array('host', 'login', 'password', 'vhost', 'exchange', 'binding', 'port') as $detail) {
         $this->connection_details[$detail] = ${$detail};
     }
     $this->connection = Celery::InitializeAMQPConnection($this->connection_details);
     #$success = $this->connection->connect();
 }
Exemple #3
0
 function __wakeup()
 {
     if ($this->connection_details) {
         $this->connection = Celery::InitializeAMQPConnection($this->connection_details);
     }
 }