Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Pub/Sub: Configurable host (for ordering) #2879

Merged
merged 2 commits into from
Jul 1, 2022
Merged

Google Pub/Sub: Configurable host (for ordering) #2879

merged 2 commits into from
Jul 1, 2022

Conversation

LukBed
Copy link
Contributor

@LukBed LukBed commented Jun 29, 2022

If ordering is required on Pub/Sub then messages must be sent only to specific region (using regional Pub/Sub endpoint). If two messages with the same orderng key are sent to two different regions, then ordering is not guaranteed.

All quotes from Pub/Sub documentation.
https://cloud.google.com/pubsub/docs/ordering
https://cloud.google.com/pubsub/docs/resource-location-restriction

If messages have the same ordering key and are in the same region, you can enable message ordering and receive the messages in the order that the Pub/Sub service receives them.

It's possible to restrict region on topic level

If you publish messages to the global Pub/Sub endpoint, Pub/Sub automatically stores the messages in the nearest Google Cloud region. Pub/Sub's topic message storage policy offers a way to ensure that messages published to a topic are never persisted outside a set of Google Cloud regions you specify, regardless of where the publish requests originate. When multiple regions are allowed by the policy, Pub/Sub chooses the nearest allowed region.

But:

If you publish a message with an ordering key and the message storage policy excludes the nearest region, the Pub/Sub service returns an error.

So the best solution is specify region when message is published.

PR constains proposition with extending publish flow, by new optional parameter with Pub/Sub host.

Example usage:
GooglePubSub.publish(topic, config, Some("europe-west1-pubsub.googleapis.com"));

@lightbend-cla-validator

@LukBed LukBed changed the title configurable Pub/Sub host when publish message in Pub/Sub module Configurable Pub/Sub host (for ordering) Jun 29, 2022
@LukBed LukBed marked this pull request as ready for review June 29, 2022 13:02
*/
def publish(topic: String,
config: PubSubConfig,
overrideHost: java.util.Optional[String],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't String be enough? If you don't want to pass a host you'd use the other overload?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, changed

@LukBed LukBed requested a review from ennru July 1, 2022 13:26
Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ennru ennru changed the title Configurable Pub/Sub host (for ordering) Google Pub/Sub: Configurable host (for ordering) Jul 1, 2022
@ennru ennru merged commit d27748d into akka:master Jul 1, 2022
@ennru
Copy link
Member

ennru commented Jul 1, 2022

Thank you!

@ennru ennru added this to the 4.0.0 milestone Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants