Google Cloud Pub/Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. This simple Kotlin command-line application demonstrates how to access the Pub/Sub API using the Google Cloud Client Library for Java.
- Enable Pub/Sub API.
- Set up authentication.
- Clone the repository
git clone https://github.com/GoogleCloudPlatform/kotlin-samples cd kotlin-samples/pubsub
- Build the project with Gradle Wrapper:
# run with "--info" flag to print potential errors ./gradlew build --info
You should now have a 'pubsub-kotlin-sample-all.jar' file under build/libs/
java -jar build/libs/pubsub-kotlin-sample-all.jar create <topic>
java -jar build/libs/pubsub-kotlin-sample-all.jar sub <topic> <subscription>
java -jar build/libs/pubsub-kotlin-sample-all.jar pub <topic> <count>
java -jar build/libs/pubsub-kotlin-sample-all.jar listen <subscription>
Subscriber will continue to listen on the topic for 5 minutes and print out message id and data as messages are received.
java -jar build/libs/pubsub-kotlin-sample-all.jar del-topic <topic>
java -jar build/libs/pubsub-kotlin-sample-all.jar del-sub <subscription>
Run the test with Gradle Wrapper
./gradlew test
- See CONTRIBUTING.md
- See LICENSE