1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
##
import unittest
import stomp
import pika
import base
import time
import os
class TestQueueProperties(base.BaseTest):
def test_subscribe(self):
destination = "/queue/queue-properties-subscribe-test"
# subscribe
self.subscribe_dest(self.conn, destination, None,
headers={
'x-message-ttl': 60000,
'x-expires': 70000,
'x-max-length': 10,
'x-max-length-bytes': 20000,
'x-dead-letter-exchange': 'dead-letter-exchange',
'x-dead-letter-routing-key': 'dead-letter-routing-key',
'x-max-priority': 6,
})
# now try to declare the queue using pika
# if the properties are the same we should
# not get any error
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='127.0.0.1', port=int(os.environ["AMQP_PORT"])))
channel = connection.channel()
channel.queue_declare(queue='queue-properties-subscribe-test',
durable=True,
arguments={
'x-message-ttl': 60000,
'x-expires': 70000,
'x-max-length': 10,
'x-max-length-bytes': 20000,
'x-dead-letter-exchange': 'dead-letter-exchange',
'x-dead-letter-routing-key': 'dead-letter-routing-key',
'x-max-priority': 6,
})
self.conn.disconnect()
connection.close()
def test_send(self):
destination = "/queue/queue-properties-send-test"
# send
self.conn.send(destination, "test1",
headers={
'x-message-ttl': 60000,
'x-expires': 70000,
'x-max-length': 10,
'x-max-length-bytes': 20000,
'x-dead-letter-exchange': 'dead-letter-exchange',
'x-dead-letter-routing-key': 'dead-letter-routing-key',
'x-max-priority': 6,
})
# now try to declare the queue using pika
# if the properties are the same we should
# not get any error
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='127.0.0.1', port=int(os.environ["AMQP_PORT"])))
channel = connection.channel()
channel.queue_declare(queue='queue-properties-send-test',
durable=True,
arguments={
'x-message-ttl': 60000,
'x-expires': 70000,
'x-max-length': 10,
'x-max-length-bytes': 20000,
'x-dead-letter-exchange': 'dead-letter-exchange',
'x-dead-letter-routing-key': 'dead-letter-routing-key',
'x-max-priority': 6,
})
self.conn.disconnect()
connection.close()
|