Skip to content

Commit c745033

Browse files
committed
Merge pull request #133 from intheair/amqp.1.0.4
pecl amqp 1.0.4 supports added
2 parents c7ee317 + 0401c4e commit c745033

15 files changed

+1770
-354
lines changed

doc/ChangeLog

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2012-09-18 Evgeniy Tekalin
2+
3+
* main/Utils/AMQP/AMQP.class.php,
4+
main/Utils/AMQP/AMQPBaseChannel.class.php,
5+
main/Utils/AMQP/AMQPBaseMessage.class.php,
6+
main/Utils/AMQP/AMQPChannelInterface.class.php,
7+
main/Utils/AMQP/AMQPPool.class.php,
8+
main/Utils/AMQP/Pecl/AMQPPecl.class.php,
9+
main/Utils/AMQP/Pecl/AMQPPeclBaseBitmask.class.php,
10+
main/Utils/AMQP/Pecl/AMQPPeclChannel.class.php,
11+
main/Utils/AMQP/AMQPInterface.class.php,
12+
main/Utils/AMQP/Pecl/AMQPPeclIncomingMessageAdapter.class.php,
13+
main/Utils/AMQP/Pecl/AMQPPeclQueueConsumer.class.php,
14+
main/Utils/AMQP/AMQPProxyChannel.class.php,
15+
main/Utils/AMQP/AMQPSelective.class.php,
16+
test/main/Utils/AMQP/AMQPPeclTest.class.php:
17+
added suppot for pecl amqp 1.0.4
18+
119
2012-09-06 Igor V. Gulyaev
220

321
* main/Base/Hstore.class.php

main/Utils/AMQP/AMQP.class.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
* AMQP stands for Advanced Message Queue Protocol, which is
1414
* an open standard middleware layer for message routing and queuing.
1515
**/
16-
abstract class AMQP
16+
abstract class AMQP implements AMQPInterface
1717
{
1818
/**
1919
* @var AMQPCredentials
2020
**/
2121
protected $credentials = null;
2222
protected $link = null;
23+
protected $alive = true;
2324

2425
/**
2526
* @var array of AMQPChannelInterface instances
@@ -49,7 +50,7 @@ abstract public function isConnected();
4950
/**
5051
* @return AMQPChannelInterface
5152
*/
52-
abstract protected function spawnChannel($id, AMQP $transport);
53+
abstract public function spawnChannel($id, AMQPInterface $transport);
5354

5455
public function __construct(AMQPCredentials $credentials)
5556
{
@@ -143,5 +144,34 @@ public function dropChannel($id)
143144

144145
return $this;
145146
}
147+
148+
/**
149+
* @return AMQPCredentials
150+
*/
151+
public function getCredentials()
152+
{
153+
return $this->credentials;
154+
}
155+
156+
/**
157+
* @return bool
158+
*/
159+
public function isAlive()
160+
{
161+
return $this->alive;
162+
}
163+
164+
/**
165+
* @param bool $alive
166+
* @return AMQP
167+
*/
168+
public function setAlive($alive)
169+
{
170+
$this->alive = ($alive === true);
171+
172+
return $this;
173+
}
174+
175+
146176
}
147177
?>

main/Utils/AMQP/AMQPBaseChannel.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ abstract class AMQPBaseChannel implements AMQPChannelInterface
1717
protected $id = null;
1818

1919
/**
20-
* @var AMQP
20+
* @var AMQPInterface
2121
**/
2222
protected $transport = null;
2323

24-
public function __construct($id, AMQP $transport)
24+
public function __construct($id, AMQPInterface $transport)
2525
{
2626
$this->id = $id;
2727
$this->transport = $transport;

main/Utils/AMQP/AMQPBaseMessage.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
**/
1515
abstract class AMQPBaseMessage
1616
{
17-
const CONTENT_TYPE = 'Content-type';
18-
const CONTENT_ENCODING = 'Content-encoding';
17+
const CONTENT_TYPE = 'content_type';
18+
const CONTENT_ENCODING = 'content_encoding';
1919
const MESSAGE_ID = 'message_id';
2020
const USER_ID = 'user_id';
2121
const APP_ID = 'app_id';
@@ -158,7 +158,7 @@ public function getAppId()
158158
**/
159159
public function setDeliveryMode($int)
160160
{
161-
Assert::isInteger($int, __METHOD__);
161+
Assert::isInteger($int, __METHOD__.": requires integer, given {$int}");
162162

163163
Assert::isTrue(
164164
in_array(
@@ -168,7 +168,7 @@ public function setDeliveryMode($int)
168168
self::DELIVERY_MODE_PERISISTENT
169169
)
170170
),
171-
__METHOD__
171+
__METHOD__.": unknown mode {$int}"
172172
);
173173

174174
$this->properties[self::DELIVERY_MODE] = $int;

main/Utils/AMQP/AMQPChannelInterface.class.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,19 @@ public function exchangeDeclare(
3737
* @return AMQPChannelInterface
3838
**/
3939
public function exchangeDelete(
40-
$name, $ifUnused = false, $ifEmpty = false
40+
$name, $ifUnused = false
4141
);
4242

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

4849
/**
4950
* @return AMQPChannelInterface
5051
**/
51-
public function exchangeUnbind($name, $queue, $routingKey);
52-
53-
/**
54-
* @see http://www.rabbitmq.com/blog/2010/10/19/exchange-to-exchange-bindings/
55-
**/
56-
public function exchangeToExchangeBind(
57-
$destination, $source, $routingKey
58-
);
59-
60-
public function exchangeToExchangeUnbind(
61-
$destination, $source, $routingKey
62-
);
52+
public function exchangeUnbind($destinationName, $sourceName, $routingKey);
6353

6454
/**
6555
* @return integer - the message count in queue
@@ -101,7 +91,7 @@ public function basicQos($prefetchSize, $prefetchCount);
10191
/**
10292
* @return AMQPIncomingMessage
10393
**/
104-
public function basicGet($queue, $noAck = true);
94+
public function basicGet($queue, $autoAck = true);
10595

10696
/**
10797
* @return AMQPChannelInterface
@@ -117,10 +107,5 @@ public function basicConsume($queue, $autoAck, AMQPConsumer $callback);
117107
* @return AMQPChannelInterface
118108
**/
119109
public function basicCancel($consumerTag);
120-
121-
/**
122-
* @return AMQPIncomingMessage
123-
**/
124-
public function getNextDelivery();
125110
}
126111
?>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/***************************************************************************
3+
* Copyright (C) 2011 by Sergey S. Sergeev *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify *
6+
* it under the terms of the GNU General Public License as published by *
7+
* the Free Software Foundation; either version 2 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
***************************************************************************/
11+
12+
/**
13+
* AMQP stands for Advanced Message Queue Protocol, which is
14+
* an open standard middleware layer for message routing and queuing.
15+
**/
16+
interface AMQPInterface
17+
{
18+
/**
19+
* @return AMQPInterface
20+
**/
21+
public function connect();
22+
23+
/**
24+
* @return AMQPInterface
25+
**/
26+
public function disconnect();
27+
28+
/**
29+
* @return AMQPInterface
30+
**/
31+
public function reconnect();
32+
33+
/**
34+
* @return boolean
35+
**/
36+
public function isConnected();
37+
38+
/**
39+
* @return AMQPInterface
40+
**/
41+
public function getLink();
42+
43+
44+
/**
45+
* @param integer $id
46+
* @throws WrongArgumentException
47+
* @return AMQPChannelInterface
48+
**/
49+
public function createChannel($id);
50+
51+
/**
52+
* @throws MissingElementException
53+
* @return AMQPChannelInterface
54+
**/
55+
public function getChannel($id);
56+
57+
58+
/**
59+
* @return array
60+
**/
61+
public function getChannelList();
62+
63+
/**
64+
* @param integer $id
65+
* @throws MissingElementException
66+
* @return AMQPChannelInterface
67+
**/
68+
public function dropChannel($id);
69+
70+
71+
/**
72+
* @return AMQPCredentials
73+
*/
74+
public function getCredentials();
75+
76+
77+
/**
78+
* @return bool
79+
*/
80+
public function isAlive();
81+
82+
83+
/**
84+
* @param bool $alive
85+
* @return AMQPInterface
86+
*/
87+
//public function setAlive($alive);
88+
}
89+
?>

main/Utils/AMQP/AMQPPool.class.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,19 @@ public function disconnect()
135135

136136
return $this;
137137
}
138+
139+
/**
140+
* @return array
141+
*/
142+
public function getList()
143+
{
144+
$list = $this->pool;
145+
146+
try {
147+
$list['default'] = $this->getLink();
148+
} catch (MissingElementException $e) {/**/}
149+
150+
return $list;
151+
}
138152
}
139153
?>

0 commit comments

Comments
 (0)