Skip to content

Invalid JSON format on Pulsar topic causes smallrye to fail #3365

@timd247

Description

@timd247

Leveraging SmallRye in a Quarkus application to exchange messages via Pulsar. On startup if a message on an incoming channel's topic is invalid JSON I get the errors below. The app doesn't process any further messages, and is essentially stuck on this message. On recycle it will continue until I purge the topic.

Since its occurring in SmallRye I don't see a way to catch this and nack the message to my failure strategy can take over, or a way to change SmallRye's behavior. I would think in this case it would nack this message.

I've seen a few other similar issues written but none related to Pulsar specifically. Some had fixes but didn't seem to impact Pulsar interaction. I am using 4.28.0, but have tried 4.34.0 with no luck either.

Thanks!

2026-04-01 23:09:55.965 myapp-7b99d66b4c-4846c ERROR [io.smallrye.reactive.messaging.provider] (vert.x-eventloop-thread-0) SRMSG00201: Error caught while processing a message in method com.foo.MyApp#processMessage: org.apache.pulsar.client.api.SchemaSerializationException: com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]
at org.apache.pulsar.client.impl.schema.reader.JacksonJsonReader.read(JacksonJsonReader.java:58)
at org.apache.pulsar.client.impl.schema.AbstractStructSchema.decode(AbstractStructSchema.java:80)
at org.apache.pulsar.client.impl.MessageImpl.decodeBySchema(MessageImpl.java:503)
at org.apache.pulsar.client.impl.MessageImpl.decode(MessageImpl.java:486)
at org.apache.pulsar.client.impl.MessageImpl.getValue(MessageImpl.java:471)
at org.apache.pulsar.client.impl.TopicMessageImpl.getValue(TopicMessageImpl.java:154)
at io.smallrye.reactive.messaging.pulsar.PulsarIncomingMessage.getPayload(PulsarIncomingMessage.java:40)
at io.smallrye.reactive.messaging.providers.helpers.ConverterUtils$1.apply(ConverterUtils.java:40)
at io.smallrye.reactive.messaging.providers.helpers.ConverterUtils$1.apply(ConverterUtils.java:31)
at io.smallrye.context.impl.wrappers.SlowContextualFunction.apply(SlowContextualFunction.java:21)
at io.smallrye.mutiny.operators.multi.MultiMapOp$MapProcessor.onItem(MultiMapOp.java:42)
at io.smallrye.mutiny.operators.multi.MultiOperatorProcessor.onItem(MultiOperatorProcessor.java:100)
at io.smallrye.reactive.messaging.providers.locals.ContextOperator$ContextMulti$ContextProcessor.lambda$onItem$1(ContextOperator.java:71)
at io.smallrye.reactive.messaging.providers.helpers.VertxContext.lambda$runOnContext$0(VertxContext.java:35)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:270)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:252)
at io.vertx.core.impl.ContextInternal.lambda$runOnContext$0(ContextInternal.java:50)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:998)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]
at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2672)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:742)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2752)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:867)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:753)
at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:356)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2117)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1500)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1515)
at org.apache.pulsar.client.impl.schema.reader.JacksonJsonReader.read(JacksonJsonReader.java:56)
... 24 more

2026-04-01 23:09:56.058 myapp-7b99d66b4c-4846c INFO [io.quarkus] (main) myapp 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.27.1) started in 15.900s. Listening on: http://0.0.0.0:8080
2026-04-01 23:09:56.058 myapp-7b99d66b4c-4846c INFO [io.quarkus] (main) Profile prod activated.
2026-04-01 23:09:56.058 myapp-7b99d66b4c-4846c INFO [io.quarkus] (main) Installed features: [cdi, kubernetes, messaging, messaging-pulsar, smallrye-context-propagation, smallrye-health, smallrye-openapi, vertx]
2026-04-01 23:09:59.658 myapp-7b99d66b4c-4846c INFO [io.smallrye.health] (vert.x-eventloop-thread-1) SRHCK01001: Reporting health down status: {"status":"DOWN","checks":[{"name":"SmallRye Reactive Messaging - readiness check","status":"DOWN","data":{"myapp_in":"[OK]","myapp_out":"[OK]","application-com.foo.MyApp#processMessage":"[KO] - com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]"}}]}
2026-04-01 23:10:09.045 myapp-7b99d66b4c-4846c INFO [io.smallrye.health] (vert.x-eventloop-thread-0) SRHCK01001: Reporting health down status: {"status":"DOWN","checks":[{"name":"SmallRye Reactive Messaging - readiness check","status":"DOWN","data":{"myapp_in":"[OK]","myapp_out":"[OK]","application-com.foo.MyApp#processMessage":"[KO] - com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]"}}]}
2026-04-01 23:10:09.046 myapp-7b99d66b4c-4846c INFO [io.smallrye.health] (vert.x-eventloop-thread-1) SRHCK01001: Reporting health down status: {"status":"DOWN","checks":[{"name":"SmallRye Reactive Messaging - liveness check","status":"DOWN","data":{"myapp_in":"[OK]","myapp_out":"[OK]","application-com.foo.MyApp#processMessage":"[KO] - com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]"}}]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions