BroadwayCloudPubSub v0.1.3 BroadwayCloudPubSub.Producer View Source

A GenStage producer that continuously receives messages from a Google Cloud Pub/Sub queue and acknowledges them after being successfully processed.

Options using GoogleApiClient (Default)

  • :subscription - Required. The name of the subscription. Example: "projects/my-project/subscriptions/my-subscription"
  • :max_number_of_messages - Optional. The maximum number of messages to be fetched per request. Default is 10.
  • :return_immediately - Optional. If this field set to true, the system will respond immediately even if it there are no messages available to return in the Pull response. Otherwise, the system may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages. Default is nil.

Additional options

  • :rest_client - Optional. A module that implements the BroadwayCloudPubSub.RestClient behaviour. This module is responsible for fetching and acknowledging the messages. Pay attention that all options passed to the producer will be forwarded to the client. It's up to the client to normalize the options it needs. Default is GoogleApiClient.

    • :receive_interval - Optional. The duration (in milliseconds) for which the producer waits before making a request for more messages. Default is 5000.
  • :token_module - Optional. A module that implements the BroadwayCloudPubSub.Token behaviour. This module is responsible for fetching an access token for Google Cloud Pub/Sub. Default is GothToken.
  • :scope - Optional. A string representing the scope or scopes to use when fetching an access token. Default is "https://www.googleapis.com/auth/pubsub"

Example

Broadway.start_link(MyBroadway,
  name: MyBroadway,
  producers: [
    default: [
      module: {BroadwayCloudPubSub.Producer,
        subscription: "projects/my-project/subscriptions/my_subscription"
      }
    ]
  ]
)

The above configuration will set up a producer that continuously receives messages from "projects/my-project/subscriptions/my_subscription" and sends them downstream.

Link to this section Summary

Link to this section Functions

Link to this function

handle_receive_messages(state) View Source