= Protobuf Jackson DataFormat
:doctitle: Protobuf Jackson
:shortname: protobuf-jackson
:artifactid: camel-jackson-protobuf
:description: Marshal POJOs to Protobuf and back using Jackson.
:since: 3.10
:supportlevel: Stable
//Manually maintained attributes
:camel-spring-boot-name: jackson-protobuf

*Since Camel {since}*

Jackson Protobuf is a Data Format which uses the
https://github.com/FasterXML/jackson/[Jackson library] with the https://github.com/FasterXML/jackson-dataformats-binary[Protobuf extension]
to unmarshal a Protobuf payload into Java objects or to marshal Java objects
into a Protobuf payload.

[TIP]
====
If you are familiar with Jackson, this Protobuf data format behaves in the
same way as its JSON counterpart, and thus can be used with classes
annotated for JSON serialization/deserialization.
====

[source,java]
-------------------------------
from("kafka:topic").
  unmarshal().protobuf(ProtobufLibrary.Jackson, JsonNode.class).
  to("log:info");
-------------------------------

== Configuring the SchemaResolver

Since Protobuf serialization is schema-based, this data format requires that you provide a SchemaResolver object
that is able to lookup the schema for each exchange that is going to be marshalled/unmarshalled.

You can add a single SchemaResolver to the registry and it will be looked up automatically.
Or you can explicitly specify the reference to a custom SchemaResolver.

== Protobuf Jackson Options

// dataformat options: START
include::partial$dataformat-options.adoc[]
// dataformat options: END


== Using custom ProtobufMapper

You can configure `JacksonProtobufDataFormat` to use a custom `ProtobufMapper` in case you need more control of the mapping configuration.

If you setup a single `ProtobufMapper` in the registry, then Camel will automatic lookup and use this `ProtobufMapper`.

== Dependencies

To use Protobuf Jackson in your camel routes you need to add the dependency
on *camel-jackson-protobuf* which implements this data format.

If you use maven you could just add the following to your pom.xml,
substituting the version number for the latest & greatest release (see
the download page for the latest versions).

[source,xml]
----------------------------------------------------------
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-jackson-protobuf</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>
----------------------------------------------------------

include::spring-boot:partial$starter.adoc[]
