Google Cloud PubSub Lite subscription in C#

539 Views Asked by At

I'm writing a software with C# language and I need to create a subscription to a Pub/Sub Lite in Google Cloud. I understood that I can't user the Google.Cloud.PubSub.V1 nuget package because it doesn't work with the Lite version. I found Google.Apis.PubsubLite.V1 nuget package but I haven't found an example of how I can create a subscription and read data from the Pub/Sub Lite. How I can do that?

2

There are 2 best solutions below

1
On BEST ANSWER

Unfortunately C# language is not supported. You can create from console or terminal using the gcloud pubsub lite-subscriptions create command.

If you want to use the API, these languages are supported:

  • Python
  • Java
  • GO

You can see this official documentation.

2
On

You can create a Lite subscription with the Cloud Console, the Google Cloud CLI, or the Pub/Sub Lite API following these next couple of steps:

  1. Go to the Lite Subscriptions page.
  2. Click Create Lite subscription.
  3. Enter a Lite subscription ID.
  4. Choose a Lite topic to receive messages from.
  5. Choose Deliver messages immediately or Deliver messages after stored.
  6. Choose a type of Starting offset.
  7. Click Create.

Also if you want to read from a subscription using a pull, you can try the example code in this asynchronous pull method, but note that it might need some changes as you are using the pubsublite library instead of the pubsub library and some things might change between libraries.