@@ -390,7 +390,7 @@ def __init__(
390390 with_attributes : bool = False ,
391391 id_label : Optional [str ] = None ,
392392 timestamp_attribute : Optional [str ] = None ,
393- enable_message_ordering : bool = False ) -> None :
393+ publish_with_ordering_key : bool = False ) -> None :
394394 """Initializes ``WriteToPubSub``.
395395
396396 Args:
@@ -406,13 +406,13 @@ def __init__(
406406 in a ReadFromPubSub PTransform to deduplicate messages.
407407 timestamp_attribute: If set, will set an attribute for each Cloud Pub/Sub
408408 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
409+ publish_with_ordering_key : If True, enables message ordering on the
410410 PublisherClient. Messages with an ordering_key will be delivered
411411 in order. Requires messages to have ordering_key set.
412412 """
413413 super ().__init__ ()
414414 self .with_attributes = with_attributes
415- self .enable_message_ordering = enable_message_ordering
415+ self .publish_with_ordering_key = publish_with_ordering_key
416416 self .id_label = id_label
417417 self .timestamp_attribute = timestamp_attribute
418418 self .project , self .topic_name = parse_topic (topic )
@@ -440,7 +440,7 @@ def expand(self, pcoll):
440440 # since _PubSubWriteDoFn._flush() is not used by Dataflow's implementation.
441441 runner = self .pipeline_options .get_all_options ().get (
442442 'runner' , '' ) if self .pipeline_options else ''
443- if 'Dataflow' in str (runner ):
443+ if 'Dataflow' in str (runner ) and self . publish_with_ordering_key :
444444 logging .warning (
445445 'WriteToPubSub ordering_key support is not available on Dataflow '
446446 'via this transform. Use the XLang WriteToPubSub path instead: '
@@ -472,9 +472,9 @@ def display_data(self):
472472 True , label = 'With Attributes' ).drop_if_none (),
473473 'timestamp_attribute' : DisplayDataItem (
474474 self .timestamp_attribute , label = 'Timestamp Attribute' ),
475- 'enable_message_ordering ' : DisplayDataItem (
476- self .enable_message_ordering ,
477- label = 'Enable Message Ordering' ).drop_if_none (),
475+ 'publish_with_ordering_key ' : DisplayDataItem (
476+ self .publish_with_ordering_key ,
477+ label = 'Publish With Ordering Key ' ).drop_if_none (),
478478 }
479479
480480
@@ -581,7 +581,7 @@ def __init__(self, transform):
581581 self .id_label = transform .id_label
582582 self .timestamp_attribute = transform .timestamp_attribute
583583 self .with_attributes = transform .with_attributes
584- self .with_ordering = transform .enable_message_ordering
584+ self .with_ordering = transform .publish_with_ordering_key
585585
586586 # TODO(https://github.com/apache/beam/issues/18939): Add support for
587587 # id_label and timestamp_attribute.
0 commit comments