Class PubSubTransport

All Implemented Interfaces:
Closeable, AutoCloseable

public final class PubSubTransport extends PollingTransport

Messaging over Google Cloud Pub/Sub's REST API, with no Google library.

cn1.messaging.url=pubsub://my-project

A destination is a topic, and a listener's group a subscription to it named <topic>.<group>; both are created on first use. Every group therefore sees every message, and the listeners of one group compete for them. Pub/Sub keeps a message only for the subscriptions that exist when it is published, so a message sent before its group ever subscribed is not delivered to that group: create the subscriptions at deployment time, or call declare(String, String) before the first send. Pub/Sub allows letters, digits and -_.~+% in a name that starts with a letter; any other character becomes -, and a name that does not start with a letter gains a t-.

Credentials, in order: the service-account key file named by cn1.messaging.pubsub.credentials or GOOGLE_APPLICATION_CREDENTIALS, then the metadata server of the Google Cloud machine the server runs on. PUBSUB_EMULATOR_HOST (or cn1.messaging.pubsub.emulator-host) sends everything, unauthenticated, to the emulator at that host:port instead.

A message is handed to one consumer for cn1.messaging.lease milliseconds (the subscription's ack deadline, at most ten minutes); one not settled in that time is delivered again. A failed message is not copied, since a copy published to the topic would reach every other group too: its deadline is moved to when the retry is due, at most ten minutes away, and its attempt is counted in this server's memory. After a restart, or when another replica receives the retry, the count starts again, so a message may be tried more often than the retry policy says before it reaches the dead-letter topic.