| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The code samples demonstrate two ways to send messages to and receive messages from Cloud Pub/Sub from your Spring application using:
When the application starts, it will do the following every ten seconds:
This sample requires Java and Maven for building the application.
Follow the Java development environment set-up instructions in the documentation.
Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Google Cloud Pub/Sub API.
Create a new topic topic-one and attach a subscription sub-one to it, then do the same for topic-two and sub-two, via the Cloud Platform Console's Cloud Pub/Sub section.
Enable application default credentials by running the command gcloud auth application-default login.
Run the following Maven or Gradle commands to run PubSubApplication:
mvn clean spring-boot:rungradle bootRunYou should observe an incoming message getting sent to topic-one, received from sub-one, sent to topic-two, and received from topic-two in the logged messages:
2020-08-10 17:29:18.807 INFO 27310 --- [ main] demo.PubSubApplication : Started PubSubApplication in 6.063 seconds (JVM running for 6.393)
2020-08-10 17:29:27.084 INFO 27310 --- [ elastic-3] demo.PubSubApplication : Sending a message via the output binder to topic-one! Payload: message-548
2020-08-10 17:29:27.604 INFO 27310 --- [sub-subscriber1] o.s.i.h.s.MessagingMethodInvokerHelper : Overriding default instance of MessageHandlerMethodFactory with provided one.
2020-08-10 17:29:27.608 INFO 27310 --- [sub-subscriber1] demo.PubSubApplication : Message arrived via an inbound channel adapter from sub-one! Payload: message-548
2020-08-10 17:29:28.269 INFO 27310 --- [bsub-publisher1] demo.PubSubApplication : Message was sent via the outbound channel adapter to topic-two!
2020-08-10 17:29:28.269 INFO 27310 --- [sub-subscriber2] o.s.i.h.s.MessagingMethodInvokerHelper : Overriding default instance of MessageHandlerMethodFactory with provided one.
2020-08-10 17:29:28.290 INFO 27310 --- [sub-subscriber2] demo.PubSubApplication : Message arrived via an input binder from topic-two! Payload: message-548
| Back | FazBrowse Home | New Git URL |