У меня есть подписка Pub/Sub с включенным свойством ключа заказа:
снимок экрана подписки
Я использую клиент Python для GCP Pub/Sub для публикации 2 сообщений:
Код: Выделить всё
from google.cloud import pubsub
import json
import typing
pubsub_client = pubsub.PublisherClient()
def fire_event_to_pubsub(
event_topic_name: str,
event_payload: dict[str, typing.Any],
order_key: str,
) -> None:
# Publish the event
topic_path = pubsub_client.topic_path(
project="project_name", topic=event_topic_name
)
message_json = json.dumps(event_payload)
# Encode the JSON string to bytes
message_bytes = message_json.encode("utf-8")
future = pubsub_client.publish(topic_path, data=message_bytes, order_key=order_key)
print(future.result())
print(
f"Published message to topic {topic_path}: {message_json} with order key {order_key}"
)
form_payload1 = {
"application_id": "50030469",
"form_path": "gs://fa-form-received-14534/application1/50030469.PDF",
"form_hash": "1111",
}
fire_event_to_pubsub(
"form_received_ordered",
form_payload1,
"50030469" + "-" + "form_name",
)
form_payload2 = {
"application_id": "50030469",
"form_path": "gs://fa-form-received-14534/application2/50030469.PDF",
"form_hash": "2222",
}
fire_event_to_pubsub(
"form_received_ordered",
form_payload2,
"50030469" + "-" + "form_name",
)
скриншот журналов
Кто-нибудь сталкивался с этим проблема раньше? Есть ли что-то, что мне не хватает?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ot-working