Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2012-09-18 Evgeniy Tekalin

* main/Utils/AMQP/AMQP.class.php,
main/Utils/AMQP/AMQPBaseChannel.class.php,
main/Utils/AMQP/AMQPBaseMessage.class.php,
main/Utils/AMQP/AMQPChannelInterface.class.php,
main/Utils/AMQP/AMQPPool.class.php,
main/Utils/AMQP/Pecl/AMQPPecl.class.php,
main/Utils/AMQP/Pecl/AMQPPeclBaseBitmask.class.php,
main/Utils/AMQP/Pecl/AMQPPeclChannel.class.php,
main/Utils/AMQP/AMQPInterface.class.php,
main/Utils/AMQP/Pecl/AMQPPeclIncomingMessageAdapter.class.php,
main/Utils/AMQP/Pecl/AMQPPeclQueueConsumer.class.php,
main/Utils/AMQP/AMQPProxyChannel.class.php,
main/Utils/AMQP/AMQPSelective.class.php,
test/main/Utils/AMQP/AMQPPeclTest.class.php:
added suppot for pecl amqp 1.0.4

2012-09-06 Igor V. Gulyaev

* main/Base/Hstore.class.php
Expand Down
34 changes: 32 additions & 2 deletions main/Utils/AMQP/AMQP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
* AMQP stands for Advanced Message Queue Protocol, which is
* an open standard middleware layer for message routing and queuing.
**/
abstract class AMQP
abstract class AMQP implements AMQPInterface
{
/**
* @var AMQPCredentials
**/
protected $credentials = null;
protected $link = null;
protected $alive = true;

/**
* @var array of AMQPChannelInterface instances
Expand Down Expand Up @@ -49,7 +50,7 @@ abstract public function isConnected();
/**
* @return AMQPChannelInterface
*/
abstract protected function spawnChannel($id, AMQP $transport);
abstract public function spawnChannel($id, AMQPInterface $transport);

public function __construct(AMQPCredentials $credentials)
{
Expand Down Expand Up @@ -143,5 +144,34 @@ public function dropChannel($id)

return $this;
}

/**
* @return AMQPCredentials
*/
public function getCredentials()
{
return $this->credentials;
}

/**
* @return bool
*/
public function isAlive()
{
return $this->alive;
}

/**
* @param bool $alive
* @return AMQP
*/
public function setAlive($alive)
{
$this->alive = ($alive === true);

return $this;
}


}
?>
4 changes: 2 additions & 2 deletions main/Utils/AMQP/AMQPBaseChannel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ abstract class AMQPBaseChannel implements AMQPChannelInterface
protected $id = null;

/**
* @var AMQP
* @var AMQPInterface
**/
protected $transport = null;

public function __construct($id, AMQP $transport)
public function __construct($id, AMQPInterface $transport)
{
$this->id = $id;
$this->transport = $transport;
Expand Down
8 changes: 4 additions & 4 deletions main/Utils/AMQP/AMQPBaseMessage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
**/
abstract class AMQPBaseMessage
{
const CONTENT_TYPE = 'Content-type';
const CONTENT_ENCODING = 'Content-encoding';
const CONTENT_TYPE = 'content_type';
const CONTENT_ENCODING = 'content_encoding';
const MESSAGE_ID = 'message_id';
const USER_ID = 'user_id';
const APP_ID = 'app_id';
Expand Down Expand Up @@ -158,7 +158,7 @@ public function getAppId()
**/
public function setDeliveryMode($int)
{
Assert::isInteger($int, __METHOD__);
Assert::isInteger($int, __METHOD__.": requires integer, given {$int}");

Assert::isTrue(
in_array(
Expand All @@ -168,7 +168,7 @@ public function setDeliveryMode($int)
self::DELIVERY_MODE_PERISISTENT
)
),
__METHOD__
__METHOD__.": unknown mode {$int}"
);

$this->properties[self::DELIVERY_MODE] = $int;
Expand Down
25 changes: 5 additions & 20 deletions main/Utils/AMQP/AMQPChannelInterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,19 @@ public function exchangeDeclare(
* @return AMQPChannelInterface
**/
public function exchangeDelete(
$name, $ifUnused = false, $ifEmpty = false
$name, $ifUnused = false
);

/**
* @see http://www.rabbitmq.com/blog/2010/10/19/exchange-to-exchange-bindings/
* @return AMQPChannelInterface
**/
public function exchangeBind($name, $queue, $routingKey);
public function exchangeBind($destinationName, $sourceName, $routingKey);

/**
* @return AMQPChannelInterface
**/
public function exchangeUnbind($name, $queue, $routingKey);

/**
* @see http://www.rabbitmq.com/blog/2010/10/19/exchange-to-exchange-bindings/
**/
public function exchangeToExchangeBind(
$destination, $source, $routingKey
);

public function exchangeToExchangeUnbind(
$destination, $source, $routingKey
);
public function exchangeUnbind($destinationName, $sourceName, $routingKey);

/**
* @return integer - the message count in queue
Expand Down Expand Up @@ -101,7 +91,7 @@ public function basicQos($prefetchSize, $prefetchCount);
/**
* @return AMQPIncomingMessage
**/
public function basicGet($queue, $noAck = true);
public function basicGet($queue, $autoAck = true);

/**
* @return AMQPChannelInterface
Expand All @@ -117,10 +107,5 @@ public function basicConsume($queue, $autoAck, AMQPConsumer $callback);
* @return AMQPChannelInterface
**/
public function basicCancel($consumerTag);

/**
* @return AMQPIncomingMessage
**/
public function getNextDelivery();
}
?>
89 changes: 89 additions & 0 deletions main/Utils/AMQP/AMQPInterface.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/***************************************************************************
* Copyright (C) 2011 by Sergey S. Sergeev *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

/**
* AMQP stands for Advanced Message Queue Protocol, which is
* an open standard middleware layer for message routing and queuing.
**/
interface AMQPInterface
{
/**
* @return AMQPInterface
**/
public function connect();

/**
* @return AMQPInterface
**/
public function disconnect();

/**
* @return AMQPInterface
**/
public function reconnect();

/**
* @return boolean
**/
public function isConnected();

/**
* @return AMQPInterface
**/
public function getLink();


/**
* @param integer $id
* @throws WrongArgumentException
* @return AMQPChannelInterface
**/
public function createChannel($id);

/**
* @throws MissingElementException
* @return AMQPChannelInterface
**/
public function getChannel($id);


/**
* @return array
**/
public function getChannelList();

/**
* @param integer $id
* @throws MissingElementException
* @return AMQPChannelInterface
**/
public function dropChannel($id);


/**
* @return AMQPCredentials
*/
public function getCredentials();


/**
* @return bool
*/
public function isAlive();


/**
* @param bool $alive
* @return AMQPInterface
*/
//public function setAlive($alive);
}
?>
14 changes: 14 additions & 0 deletions main/Utils/AMQP/AMQPPool.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,19 @@ public function disconnect()

return $this;
}

/**
* @return array
*/
public function getList()
{
$list = $this->pool;

try {
$list['default'] = $this->getLink();
} catch (MissingElementException $e) {/**/}

return $list;
}
}
?>
Loading