Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment utiliser Pub/Sub dans des applications Java créées avec le framework Spring.
Spring Cloud GCP comporte plusieurs modules pour envoyer des messages aux sujets Pub/Sub et recevoir des messages depuis des abonnements Pub/Sub à l'aide du framework Spring. Vous pouvez utiliser ces modules indépendamment ou les combiner pour différents cas d'utilisation :
Spring Cloud GCP Pub/Sub Starter vous permet d'envoyer et de recevoir des messages à l'aide de classes d'assistance et d'appeler la bibliothèque cliente Java pour Pub/Sub pour des scénarios plus avancés.
Les adaptateurs de canal d'intégration Spring pour Pub/Sub vous permettent de connecter les canaux de message d'intégration de Spring à Pub/Sub.
Spring Cloud Stream Binder pour Pub/Sub vous permet d'utiliser Pub/Sub comme middleware de messagerie dans les applications Spring Cloud Stream.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Using Pub/Sub in Spring applications\n\nThis page describes how to use Pub/Sub in Java applications built with\nthe [Spring Framework](https://spring.io/projects/spring-framework).\n\n[Spring Cloud GCP](https://googlecloudplatform.github.io/spring-cloud-gcp/reference/html/index.html) has several modules for sending\nmessages to Pub/Sub topics and receiving messages from\nPub/Sub subscriptions using the Spring Framework. You can use\nthese modules independently or combine them for different use cases:\n\n- **Spring Cloud GCP Pub/Sub Starter** lets you send and receive messages using helper classes and call the Pub/Sub Java client library for more advanced scenarios.\n- **Spring Integration Channel Adapters for Pub/Sub** let you connect Spring Integration [Message Channels](https://docs.spring.io/spring-integration/reference/channel.html) with Pub/Sub.\n- **Spring Cloud Stream Binder for Pub/Sub** lets you use Pub/Sub as messaging middleware in Spring Cloud Stream applications.\n\n| **Note:** The [Spring Cloud GCP](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-pubsub/src)Library does not provide access to [AckReplyConsumerWithResponse](/java/docs/reference/google-cloud-pubsub/latest/com.google.cloud.pubsub.v1.AckReplyConsumerWithResponse), which is a required module to implement the exactly-once feature using the Java client library.\n\nUsing Spring Cloud GCP Pub/Sub Starter\n--------------------------------------\n\nFollow [Spring Framework on Google Cloud reference guide - Cloud Pub/Sub](https://googlecloudplatform.github.io/spring-cloud-gcp/reference/html/index.html#cloud-pubsub)\nfor further details on the Spring Cloud GCP Pub/Sub Starter and instructions on how to use it.\n\nUsing Spring Integration channel adapters\n-----------------------------------------\n\nFollow [Spring Framework on Google Cloud reference guide - Channel Adapters for Cloud Pub/Sub](https://googlecloudplatform.github.io/spring-cloud-gcp/reference/html/index.html#channel-adapters-for-cloud-pubsub)\nfor further details on the Spring Integration channel adapters and instructions on how to use them.\n\nUsing Spring Cloud Stream Binder\n--------------------------------\n\nFollow [Spring Framework on Google Cloud reference guide - Spring Cloud Stream Binder for Cloud Pub/Sub](https://googlecloudplatform.github.io/spring-cloud-gcp/reference/html/index.html#spring-cloud-stream)\nfor further details on the Spring Cloud Stream Binder and instructions on how to use it."]]