Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions spring-pulsar-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@ javaPlatform {
ext {
assertjVersion = '3.23.1'
awaitilityVersion = '4.2.0'
caffeineVersion = '3.1.1'
googleJsr305Version = '3.0.2'
hamcrestVersion = '2.2'
hibernateValidationVersion = '7.0.4.Final'
jacksonBomVersion = '2.13.3'
jaywayJsonPathVersion = '2.6.0'
junitJupiterVersion = '5.9.0'
pulsarVersion = '2.10.1'
log4jVersion = '2.18.0'
mockitoVersion = '4.6.1'
reactorVersion = '2020.0.17'
protobufJavaVersion = '3.21.5'
pulsarTestcontainersVersion = '1.17.3'
pulsarVersion = '2.10.1'
reactorVersion = '2020.0.17'
springBootVersion = '3.0.0-SNAPSHOT'
springRetryVersion = '1.3.3'
springVersion = '6.0.0-SNAPSHOT'
caffeineVersion = '3.1.1'
}

dependencies {
Expand All @@ -38,6 +39,7 @@ dependencies {
constraints {
api "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
api "com.google.code.findbugs:jsr305:$googleJsr305Version"
api "com.google.protobuf:protobuf-java:$protobufJavaVersion"
api "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"
api "org.apache.pulsar:pulsar-client:$pulsarVersion"
api "org.apache.pulsar:pulsar-client-admin:$pulsarVersion"
Expand Down
10 changes: 9 additions & 1 deletion spring-pulsar-docs/src/main/asciidoc/pulsar.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,16 @@ public void listen(Foo foo) {
----
====

On the producer side also, for the Java primitive types, the framework can infer the Schema, but for any other types, you need set that on the `PulsarTemmplate`.
On the producer side also, for the Java primitive types, the framework can infer the Schema, but for any other types, you need to set them on the `PulsarTemplate` as shown below.

====
[source, java]
----
template.setSchema(JSONSchema.of(Foo.class));
----
====

TIP: Complex Schema types that are currently supported are JSON, AVRO, PROTOBUF, and KEY_VALUE. For KEY_VALUE schemata, only INLINE encoding is supported.

==== Intercepting messages

Expand Down
1 change: 1 addition & 0 deletions spring-pulsar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description = 'Spring Pulsar Support'

dependencies {
api 'com.github.ben-manes.caffeine:caffeine'
api 'com.google.protobuf:protobuf-java'
api 'org.apache.pulsar:pulsar-client'
api 'org.apache.pulsar:pulsar-client-admin'
api 'org.apache.pulsar:pulsar-client-admin-api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.impl.schema.AvroSchema;
import org.apache.pulsar.client.impl.schema.JSONSchema;
import org.apache.pulsar.client.impl.schema.ProtobufSchema;
import org.apache.pulsar.common.schema.KeyValueEncodingType;
import org.apache.pulsar.common.schema.SchemaType;

Expand All @@ -54,6 +55,8 @@
import org.springframework.pulsar.support.converter.PulsarRecordMessageConverter;
import org.springframework.util.Assert;

import com.google.protobuf.GeneratedMessageV3;

/**
* A {@link PulsarListenerEndpoint} providing the method to invoke to process an incoming
* message for this endpoint.
Expand Down Expand Up @@ -154,6 +157,12 @@ protected PulsarMessagingMessageListenerAdapter<V> createMessageListener(PulsarM
Schema<?> messageSchema = getMessageSchema(messageParameter, AvroSchema::of);
pulsarContainerProperties.setSchema(messageSchema);
}
case PROTOBUF -> {
@SuppressWarnings("unchecked")
Schema<?> messageSchema = getMessageSchema(messageParameter,
(c -> ProtobufSchema.of((Class<? extends GeneratedMessageV3>) c)));
pulsarContainerProperties.setSchema(messageSchema);
}
case KEY_VALUE -> {
Schema<?> messageSchema = getMessageKeyValueSchema(messageParameter);
pulsarContainerProperties.setSchema(messageSchema);
Expand Down
Loading