@@ -389,7 +389,8 @@ def __init__(
389389 topic : str ,
390390 with_attributes : bool = False ,
391391 id_label : Optional [str ] = None ,
392- timestamp_attribute : Optional [str ] = None ) -> None :
392+ timestamp_attribute : Optional [str ] = None ,
393+ enable_message_ordering : bool = False ) -> None :
393394 """Initializes ``WriteToPubSub``.
394395
395396 Args:
@@ -405,9 +406,13 @@ def __init__(
405406 in a ReadFromPubSub PTransform to deduplicate messages.
406407 timestamp_attribute: If set, will set an attribute for each Cloud Pub/Sub
407408 message with the given name and the message's publish time as the value.
409+ enable_message_ordering: If True, enables message ordering on the
410+ PublisherClient. Messages with an ordering_key will be delivered
411+ in order. Requires messages to have ordering_key set.
408412 """
409413 super ().__init__ ()
410414 self .with_attributes = with_attributes
415+ self .enable_message_ordering = enable_message_ordering
411416 self .id_label = id_label
412417 self .timestamp_attribute = timestamp_attribute
413418 self .project , self .topic_name = parse_topic (topic )
@@ -467,6 +472,9 @@ def display_data(self):
467472 True , label = 'With Attributes' ).drop_if_none (),
468473 'timestamp_attribute' : DisplayDataItem (
469474 self .timestamp_attribute , label = 'Timestamp Attribute' ),
475+ 'enable_message_ordering' : DisplayDataItem (
476+ self .enable_message_ordering ,
477+ label = 'Enable Message Ordering' ).drop_if_none (),
470478 }
471479
472480
@@ -573,7 +581,7 @@ def __init__(self, transform):
573581 self .id_label = transform .id_label
574582 self .timestamp_attribute = transform .timestamp_attribute
575583 self .with_attributes = transform .with_attributes
576- self .with_ordering = transform .with_attributes
584+ self .with_ordering = transform .enable_message_ordering
577585
578586 # TODO(https://github.com/apache/beam/issues/18939): Add support for
579587 # id_label and timestamp_attribute.
0 commit comments