Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Cloud Eventarc - Pub/Sub tutorial

This sample shows how to create a service that processes Pub/Sub messages.

For more details on how to work with this sample read the Google Cloud Run Java Samples README.

Run in Google Cloud

Dependencies

  • Spring Boot: Web server framework.
  • Jib: Container build tool.
  • Junit + SpringBootTest: [development] Test running framework.
  • MockMVC: [development] Integration testing support framework.

Quickstart

Create a Cloud Pub/Sub topic:

gcloud pubsub topics create my-topic

Use the Jib Maven Plugin to build and push your container image:

mvn jib:build -Dimage gcr.io/$(gcloud config get-value project)/cloudrun-events-pubsub

Deploy your Cloud Run service:

gcloud run deploy cloudrun-events-pubsub \
--image gcr.io/$(gcloud config get-value project)/cloudrun-events-pubsub

Create a Cloud Pub/Sub trigger:

gcloud alpha events triggers create pubsub-trigger \
--target-service cloudrun-events-pubsub \
--type com.google.cloud.pubsub.topic.publish \
--parameters topic=my-topic

Test

Test your Cloud Run service by publishing a message to the topic:

gcloud pubsub topics publish my-topic --message="Hello there"

You may observe the Run service receiving an event in Cloud Logging.