diff --git a/spring-pulsar-docs/src/main/asciidoc/attributes.adoc b/spring-pulsar-docs/src/main/asciidoc/attributes.adoc index e1f6cbb3..5134a6f1 100644 --- a/spring-pulsar-docs/src/main/asciidoc/attributes.adoc +++ b/spring-pulsar-docs/src/main/asciidoc/attributes.adoc @@ -12,6 +12,8 @@ :github: https://github.com/spring-projects-experimental/spring-pulsar :javadocs: https://docs.spring.io/spring-pulsar/docs/{spring-pulsar-version}/api :spring-boot-docs: https://docs.spring.io/spring-boot/docs/{spring-boot-version}/reference/htmlsingle +:spring-cloud-stream-docs: https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/ +:spring-cloud-function: https://spring.io/projects/spring-cloud-function :apache-pulsar-docs: https://pulsar.apache.org/docs/2.11.x :apache-pulsar-io-docs: {apache-pulsar-docs}/io-connectors diff --git a/spring-pulsar-docs/src/main/asciidoc/index.adoc b/spring-pulsar-docs/src/main/asciidoc/index.adoc index 021a7e39..ac813645 100644 --- a/spring-pulsar-docs/src/main/asciidoc/index.adoc +++ b/spring-pulsar-docs/src/main/asciidoc/index.adoc @@ -25,6 +25,8 @@ include::pulsar-function.adoc[leveloffset=+2] include::observability.adoc[leveloffset=+2] +include::pulsar-binder.adoc[leveloffset=+2] + :sectnums!: [[other-resources]] == Other Resources diff --git a/spring-pulsar-docs/src/main/asciidoc/pulsar-binder.adoc b/spring-pulsar-docs/src/main/asciidoc/pulsar-binder.adoc new file mode 100644 index 00000000..a21516de --- /dev/null +++ b/spring-pulsar-docs/src/main/asciidoc/pulsar-binder.adoc @@ -0,0 +1,128 @@ +[[pulsar-binder]] += Spring Cloud Stream Binder for Apache Pulsar +include::attributes.adoc[] + +Spring for Apache Pulsar provides a binder for Spring Cloud Stream that we can use for building event driven microservices using pub-sub paradigms. +In this section, we will go through the basic details of this binder. + +TIP: For those who are unfamiliar with the concepts in Spring Cloud Stream, you may want to go through the main {spring-cloud-stream-docs}[reference docs] for Spring Cloud Stream to gain an understanding of the core concepts. + +== Usage + +To use Apache Pulsar binder for Spring Cloud Stream, we need to include the following dependency to your application. + +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] +.Maven +---- + + + org.springframework.pulsar + spring-pulsar-spring-cloud-stream-binder + {spring-pulsar-version} + + +---- + +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] +.Gradle +---- +dependencies { + implementation 'org.springframework.pulsar:spring-pulsar-spring-cloud-stream-binder:{spring-pulsar-version}' +} +---- + +== Overview + +In a nutshell, the Spring Cloud Stream binder for Apache Pulsar allows the applications to focus on the business logic rather than dealing with the lower-level details of managing and maintaining Pulsar. +The binder takes care of all those details for the application developer. +Spring Cloud Stream brings a powerful programming model that is based on {spring-cloud-function}[Spring Cloud Function] that allows the app developer to write complex event driven application using a functional style. +Applications can start from a middleware neutral manner and then map Pulsar topics as destinations in Spring Cloud Stream through Spring Boot configuration properties. +Spring Cloud Stream is built on top of Spring Boot and when writing an event driven microservice using Spring Cloud Stream, you are essentially writing a Boot application. +Here is a very simple Spring Cloud Stream application. + +==== +[source, java] +---- +@SpringBootApplication +public class SpringPulsarBinderSampleApp { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public static void main(String[] args) { + SpringApplication.run(SpringPulsarBinderSampleApp.class, args); + } + + @Bean + public Supplier