Created
April 9, 2022 04:31
-
-
Save bijukunjummen/ff89e793cab7669c1abe0b6895dbf757 to your computer and use it in GitHub Desktop.
Publish to Cloud Pub/Sub using Spring Cloud GCP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Mono<Void> publish(Message message) { | |
| ByteString data = ByteString.copyFromUtf8(JsonUtils.writeValueAsString(message, objectMapper)); | |
| PubsubMessage pubSubMessage = PubsubMessage.newBuilder().setData(data).build(); | |
| return Mono.fromFuture(pubSubTemplate.publish(pubSubProperties.topic(), pubSubMessage).completable()).then(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment