GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — KeyValue schema encoding types INLINE vs SEPARATED · apache/pulsar · Discussion #25849

KeyValue schema encoding types INLINE vs SEPARATED #25849

Answered by Slymaster
kasparjarek asked this question in Q&A
KeyValue schema encoding types INLINE vs SEPARATED #25849
@kasparjarek kasparjarek
May 21, 2026 · 1 comment
Answered by Slymaster Return to top
Discussion options
  • Uh oh!

    There was an error while loading. Please reload this page.

  • Uh oh!

    There was an error while loading. Please reload this page.

kasparjarek
May 21, 2026

I have a few questions regarding KeyValue schema encoding types (INLINE vs SEPARATED). I have seen conflicting answers from AI bots and was unable to find clear information in the documentation.

  1. Is it true that when using INLINE encoding, the key is not used for routing decisions and therefore the ordering guarantees of the Key_Shared subscription type are lost?
  2. What are the practical advantages and disadvantages of these two encoding types? If the statement above is true, why would I ever want to use INLINE type?

Thank you

You must be logged in to vote
All reactions
Answered by Slymaster Sep 29, 2026

The key inside your KeyValue<K,V> object and the Pulsar message key used for routing are separate in the Java client.

  • INLINE serializes both parts into the payload. It does not automatically copy the object's key into the message-key metadata.
  • SEPARATED serializes the object's key into the message-key metadata and puts only the value in the payload.

You can see both paths in TypedMessageBuilderImpl, v4.0.8 and its separated-key implementation.

Your first statement is correct if you use INLINE without setting a message key or ordering key: Key_Shared cannot group messages by a key that exists only inside the payload. However, INLINE itself does not prevent keyed routing. You can supply t…

View full answer

Replies: 1 comment

Comment options
  • Uh oh!

    There was an error while loading. Please reload this page.

Slymaster
Sep 29, 2026

The key inside your KeyValue<K,V> object and the Pulsar message key used for routing are separate in the Java client.

  • INLINE serializes both parts into the payload. It does not automatically copy the object's key into the message-key metadata.
  • SEPARATED serializes the object's key into the message-key metadata and puts only the value in the payload.

You can see both paths in TypedMessageBuilderImpl, v4.0.8 and its separated-key implementation.

Your first statement is correct if you use INLINE without setting a message key or ordering key: Key_Shared cannot group messages by a key that exists only inside the payload. However, INLINE itself does not prevent keyed routing. You can supply the message key separately:

var schema = Schema.KeyValue(
        Schema.STRING, Schema.STRING, KeyValueEncodingType.INLINE);

var producer = client.newProducer(schema)
        .topic("persistent://public/default/events")
        .enableBatching(false)
        .create();

producer.newMessage()
        .key("customer-42")
        .value(new KeyValue<>("customer-42", "updated"))
        .send();

This is supported by the Java client's tests.

SEPARATED is convenient when the object's key should also be the routing/compaction key. INLINE is useful when you want a self-contained serialized key/value payload, or want routing to use a different key.

For either encoding, Key_Shared requires batching to be disabled or key-based. Default batching can mix keys and defeat the intended routing.

You must be logged in to vote
All reactions
0 replies
Answer selected by kasparjarek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
@kasparjarek @Slymaster
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.