use same rabittmq connection

This commit is contained in:
2022-03-24 10:15:44 +01:00
parent 25207bb062
commit cd71577e71
6 changed files with 17 additions and 23 deletions
+2 -12
View File
@@ -4,7 +4,6 @@ import string
import threading
import time
import pika
from playwright.sync_api import sync_playwright
import params
@@ -136,25 +135,17 @@ class CommandorPage:
id = url.split("/")[-1]
result = ReserveResultPojo(type=PublishType.SUCCESS, phone=contact.phone, message=message, url=url,
firstName=contact.first_name, lastName=contact.last_name, email=contact.mail,
passport=contact.passport)
passport=contact.passport, ccid=contact.ccid)
result.id = id
_credentials = pika.PlainCredentials('scrapy_rabbitmq', '4x!hReCbA5v3heKWfPJV-Y')
connection = pika.BlockingConnection(
pika.ConnectionParameters(host=params.rabittMQ_host,
port=params.rabittMQ_port,
credentials=_credentials))
channel = connection.channel()
channel = params.rabittmq_connection.channel()
# default exchange, for 'hello' queue
print("will publish message:" + result.to_json())
channel.basic_publish(exchange='', routing_key=APPOINTMENT_QUEUE,
body=result.to_json())
connection.close()
def get_random_id_number_for_proxy() -> str:
# write_the_valid_profiles_to_excel()
S = 8 # number of characters in the string.
# call random.choices() string module to find the string in Uppercase + numeric data.
ran = ''.join(random.choices(string.digits, k=S))
id_number = str(ran)
print("The randomly generated string is : " + str(ran)) # print the random data
@@ -162,7 +153,6 @@ def get_random_id_number_for_proxy() -> str:
def get_random_id_number() -> str:
# write_the_valid_profiles_to_excel()
S = 8 # number of characters in the string.
ran = ''.join(random.choices(string.digits, k=S))
id_number = "57" + str(ran)