atk-common 3.13.0__py3-none-any.whl → 3.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atk_common/classes/rabbitmq_consumer.py +5 -3
- atk_common/utils/consumer_retry_handler.py +8 -2
- {atk_common-3.13.0.dist-info → atk_common-3.15.0.dist-info}/METADATA +1 -1
- {atk_common-3.13.0.dist-info → atk_common-3.15.0.dist-info}/RECORD +7 -7
- {atk_common-3.13.0.dist-info → atk_common-3.15.0.dist-info}/WHEEL +0 -0
- {atk_common-3.13.0.dist-info → atk_common-3.15.0.dist-info}/licenses/license.txt +0 -0
- {atk_common-3.13.0.dist-info → atk_common-3.15.0.dist-info}/top_level.txt +0 -0
@@ -10,7 +10,7 @@ CONNECTION_ERRORS = (
|
|
10
10
|
)
|
11
11
|
|
12
12
|
class RabbitMQConsumer:
|
13
|
-
def __init__(self, queue_name, user, pwd, host, vhost, dlx, dlq, content_type, message_handler, logger: ILogger):
|
13
|
+
def __init__(self, queue_name, user, pwd, host, vhost, dlx, dlq, content_type, message_handler, prefetch_count, logger: ILogger):
|
14
14
|
self.logger = logger
|
15
15
|
|
16
16
|
rabbit_url = 'amqp://' + user + ':' + pwd + '@' + host + '/' + vhost
|
@@ -26,8 +26,9 @@ class RabbitMQConsumer:
|
|
26
26
|
else:
|
27
27
|
queue = Queue(name=queue_name)
|
28
28
|
self.queue = queue
|
29
|
-
self.content_type = content_type
|
30
|
-
self.message_handler = message_handler
|
29
|
+
self.content_type = content_type
|
30
|
+
self.message_handler = message_handler
|
31
|
+
self.prefetch_count = prefetch_count
|
31
32
|
|
32
33
|
def _consume(self):
|
33
34
|
conn = self._establish_connection()
|
@@ -59,6 +60,7 @@ class RabbitMQConsumer:
|
|
59
60
|
accept=[self.content_type] if self.content_type else None)
|
60
61
|
consumer.revive(channel)
|
61
62
|
consumer.consume()
|
63
|
+
consumer.qos(prefetch_count=self.prefetch_count, apply_global=False)
|
62
64
|
self.logger.info("Connection revived!")
|
63
65
|
return revived_connection
|
64
66
|
|
@@ -15,6 +15,12 @@ def create_retry_handler(process_func, connection, exchange, routing_key, should
|
|
15
15
|
|
16
16
|
def handler(body, message):
|
17
17
|
try:
|
18
|
+
retry_policy = {
|
19
|
+
"max_retries": 5,
|
20
|
+
"interval_start": 0.2,
|
21
|
+
"interval_step": 0.5,
|
22
|
+
"interval_max": 5,
|
23
|
+
}
|
18
24
|
process_response = process_func(body, message)
|
19
25
|
if is_response_ok(process_response):
|
20
26
|
message.ack()
|
@@ -29,11 +35,13 @@ def create_retry_handler(process_func, connection, exchange, routing_key, should
|
|
29
35
|
exchange=exchange,
|
30
36
|
routing_key=routing_key,
|
31
37
|
retry=True,
|
38
|
+
retry_policy=retry_policy,
|
32
39
|
declare=declare,
|
33
40
|
content_type=message.content_type,
|
34
41
|
content_encoding=message.content_encoding,
|
35
42
|
headers=message.headers,
|
36
43
|
timestamp=message.properties.get("timestamp"),
|
44
|
+
mandatory=True,
|
37
45
|
delivery_mode=2
|
38
46
|
)
|
39
47
|
message.ack()
|
@@ -44,8 +52,6 @@ def create_retry_handler(process_func, connection, exchange, routing_key, should
|
|
44
52
|
if should_retry(process_response):
|
45
53
|
logger.error("Sending to DLQ...")
|
46
54
|
message.reject(requeue=False)
|
47
|
-
# bo_logger.error("Requing...")
|
48
|
-
# message.requeue()
|
49
55
|
else:
|
50
56
|
logger.error("Discarding message...")
|
51
57
|
message.ack()
|
@@ -22,7 +22,7 @@ atk_common/classes/docker_handler.py,sha256=VNJecc2ZWcpwNBa61QTGM_kYrsoZTjktMcFR
|
|
22
22
|
atk_common/classes/env_handler.py,sha256=h3snKwHwDvfc2dt1vgHasqv8n_vnsI9J2MAr-XM5oow,1283
|
23
23
|
atk_common/classes/error_handler.py,sha256=DgRzWx4Yu8PKX1bqj55aWhrkqb92ebDaEwtxgKhTLls,3270
|
24
24
|
atk_common/classes/http_response_handler.py,sha256=qgtGyEwUe4lIiayS6syWanr2VE6GaKHddazNL_PxEFM,2327
|
25
|
-
atk_common/classes/rabbitmq_consumer.py,sha256=
|
25
|
+
atk_common/classes/rabbitmq_consumer.py,sha256=alqn12Hfdl0dc4B0lMe4jNB4sYDzsRWwcWSwY-wGPzE,3004
|
26
26
|
atk_common/enums/__init__.py,sha256=JjIQ_bHIGxfWtf9Mlj36Gumll4otgLj0cR_oXF46XyY,2736
|
27
27
|
atk_common/enums/api_error_type_enum.py,sha256=9oW6ZaZ3lhMwR8r2sVNWGliS9C_jV-otiOYdezAuTp0,91
|
28
28
|
atk_common/enums/camera_cabinet_type_enum.py,sha256=U2NVrsTCBgaMRwYJamnjshAW8Y7xlOVjvUzakdgVH9A,90
|
@@ -71,7 +71,7 @@ atk_common/interfaces/error_handler_interface.py,sha256=ErhQ69T3fCYUl6sS5GwiMgW-
|
|
71
71
|
atk_common/interfaces/http_response_handler_interface.py,sha256=Cl_njN_klHz1u06FCJPata1dua1w4Cs-Qt9Rg7uaB1c,169
|
72
72
|
atk_common/interfaces/logger_interface.py,sha256=jK1gwkB_XmvqsTENhfOsw2QBplay16yVzc_qDSkgFyk,423
|
73
73
|
atk_common/utils/__init__.py,sha256=hU5xicoI6dXRDz0gQADIDo2YbiL2UptTehVBISReIDo,1857
|
74
|
-
atk_common/utils/consumer_retry_handler.py,sha256=
|
74
|
+
atk_common/utils/consumer_retry_handler.py,sha256=aumO5iwVP90UI3aYpMQeQXuDElSZfSmI5wxz6pbNnJY,2811
|
75
75
|
atk_common/utils/datetime_utils.py,sha256=h3tv6iPD4peBXLCAcws41nuxIM4KpR1vk71LYXTDHKo,3662
|
76
76
|
atk_common/utils/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
|
77
77
|
atk_common/utils/default_should_retry.py,sha256=qghFbU71ygC8ARc0jkbDlxwZtwEPUqO8vGhIhGJX-Ao,838
|
@@ -82,7 +82,7 @@ atk_common/utils/http_utils.py,sha256=eSRuQeDgN0ISQdByZqE6cIGXoorcAXz7PEtVntHUKA
|
|
82
82
|
atk_common/utils/internal_response_utils.py,sha256=2X9eLFEy1pO3Aesj1IRXg2yprwNcBDM5_dXaA5vfmMI,694
|
83
83
|
atk_common/utils/mq_utils.py,sha256=DmVcXIZHG45p7cQVvgen6OT8QbW_UifFFJGJBybTkJQ,1835
|
84
84
|
atk_common/utils/str_utils.py,sha256=sg3jwTTIfQvgGP-lcY5Xh4PXXhKWse_4HswBQYQKEo4,260
|
85
|
-
atk_common-3.
|
85
|
+
atk_common-3.15.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
|
86
86
|
atk_package/__init__.py,sha256=okIFEefQhQrw6DZg6oCEVWsEdkVCk-57VXBW0IUG_wU,834
|
87
87
|
atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
|
88
88
|
atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
|
@@ -95,7 +95,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
|
|
95
95
|
atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
|
96
96
|
atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
|
97
97
|
shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
98
|
-
atk_common-3.
|
99
|
-
atk_common-3.
|
100
|
-
atk_common-3.
|
101
|
-
atk_common-3.
|
98
|
+
atk_common-3.15.0.dist-info/METADATA,sha256=a8E6d-jE1YhKZwFb90pPdAVyn2TTen_bcvh8OPInjLo,1761
|
99
|
+
atk_common-3.15.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
100
|
+
atk_common-3.15.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
|
101
|
+
atk_common-3.15.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|