Skip to content

Kafka transport binding#300

Closed
longit644 wants to merge 1 commit into
cloudevents:masterfrom
longit644:feature/kafka-transport-binding
Closed

Kafka transport binding#300
longit644 wants to merge 1 commit into
cloudevents:masterfrom
longit644:feature/kafka-transport-binding

Conversation

@longit644
Copy link
Copy Markdown

@longit644 longit644 commented Sep 1, 2018

I'd like to propose a Kafka transport binding for CloudEvents, similar to the HTTP binding and proposed NATS, MQTT, AMQP bindings.

Signed-off-by: Long Bui bnlong@fossil.com

Comment thread kafka-transport-binding.md Outdated

## Abstract

The [Kafka][Kafka] Transport Binding for CloudEvents defines how events are mapped to [Kafka messages][kafka-Message-Format].
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please wrap at 80 cols

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Sep 1, 2018

CI error is ok and will automatically be fixed once merged.

Signed-off-by: Long Bui <bnlong@fossil.com>
placed into the Kafka message value section
using an [event format](#14-event-formats).

In the *binary* content mode, the value of the event `data` attribute is placed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need an RFC2119 keyword in here, perhaps s/is placed/MUST be placed/ ??

In the *binary* content mode, the value of the event `data` attribute is placed
into the Kafka message's value section as-is, with
the `kafka_contentType` header value declaring its media type; all other event
attributes are mapped to the Kafka message's
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe: s/are mapped/MUST be mapped/

With Kafka 0.11.0.0 and above, the content mode is chosen by the sender of the
event. Protocol usage patterns that might allow solicitation of events using a
particular content mode might be defined by an application, but are not defined
here.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space before "here"

#### 3.1.3. Metadata Headers

All [CloudEvents][CE] attributes with exception of `data` MUST be individually
mapped to and from the Header fields in the Kafka message.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any rule needed w.r.t. the names used? Case of the names?


##### 3.1.3.1 User Property Names

Cloud Event attributes are prefixed with "cloudEvents_" for use in the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space between "Cloud" and "Event"

All [CloudEvents][CE] attributes with exception of `data` MUST be individually
mapped to and from the Header fields in the Kafka message.

##### 3.1.3.1 User Property Names
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between "User Properties" and "Metadata Headers" ?

the Kafka `kafka_contentType` header; all other CloudEvents attributes
are mapped to Kafka Header fields with prefix `cloudEvents_`.

Mind that `cloudEvents_` here does refer to the event `data`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this line, what do you mean by "cloudEvents_ here" ?

Copy link
Copy Markdown
Author

@longit644 longit644 Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloudEvents_ is the prefix of CloudEvents context attributes, I want to mark these attributes as CloudEvents context attributes, except for contentType because it's a common attribute.

The chosen [event format](#14-event-formats) defines how all attributes,
including the `data` attribute, are represented.

The event metadata and data is then rendered in accordance with the event
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is/are/ I think

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be using from RFC2119 keywords in here some place?


#### 3.2.1. Kafka Content-Type

The [Kafka `kafka_contentType`] property field is set to the media type
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe s/is set/MUST be set/

format][Kafka-Message-Format] specification.


#### 3.1.4 Examples
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but since there's just one example you can remove the 's' at the end

Implementations MAY include the same Kafka headers as defined for the
[binary mode](#313-metadata-headers).

#### 3.2.4 Examples
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one example

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Sep 7, 2018

overall this looks good to me, but I'm not a Kafka expert, and I think my questions/edits are relatively minor. It does seem like there might be some spots where more RFC2119 keywords should be used, so perhaps a Kafka expert read this with an eye for that.

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Sep 13, 2018

@bnlong4417 can you address the comments in here - then we may be able to resolve this on next week's call

@clemensv
Copy link
Copy Markdown
Contributor

I'm in generally in favor of having such a binding, and haven't yet been able to make the time to review this proposal side-by-side with the Kafka protocol spec, but promise to do so this week.

I would like to use this PR to close some @duglin assigned homework, namely the AI related to issue #218 .

We should have an explicit mechanism in here that states how to derive the partitionKey that Kafka needs and that this proposal here doesn't yet seem to mention except in the example. I don't have a proposal yet for how to do that.

The receiver of the event can distinguish between the two content modes by
inspecting the `kafka_contentType` property of the Kafka message. If the value
of the `kafka_contentType` property is prefixed with the CloudEvents media type
`application/cloudevents`, indicating the use of a known [event
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this has been copied from the HTTP binding, which means we now have two different specs specifying this MIME type. That's not ideal, it should only be specified in one place. So I think this should be added to the main spec to say what its MIME type is, and then both this and the HTTP binding can reference that, plus the JSON spec should be the authoritative spec that says that it is the format for application/cloudevents+json, not this and the HTTP binding.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I borrowed it from HTTP specs. I think it should be moved to main specs too.


In the *binary* content mode, the value of the event `data` attribute is placed
into the Kafka message's value section as-is, with
the `kafka_contentType` header value declaring its media type; all other event
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does kafka_contentType come from? As far as I can work out, this is unique to this spec. While there isn't a standard header in Kafka for content type, it does appear that there are libraries out there that do put a content type header, and it appears to me that there is some consensus around contentType. Even without that, I don't think kafka_contentType makes sense, since of course it's Kafka. If this header is specific to CloudEvents, and you want to namespace it, then the prefix should be couldevents, since a CloudEvents spec like this has no business defining a header in the kafka namespace.

Copy link
Copy Markdown
Author

@longit644 longit644 Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there isn't a standard header in Kafka for the content type. So I used the Spring's format for kafka_contentType at here: https://github.com/spring-projects/spring-kafka/blob/996f8649d562cb7a2b15af42ab0bea64b510d961/spring-kafka/src/main/java/org/springframework/kafka/support/KafkaHeaders.java#L32

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Sep 20, 2018

@bnlong4417 there are some comments/questions - can you try to address those? We can't consider adopting this until those are addressed.

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Oct 15, 2018

@bnlong4417 are you still interested in us adopting this PR? There are some updates needed if so.

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Oct 16, 2018

@bnlong4417 we haven't heard from you since you opened this PR. Please speak-up before this Thursday's call if you're interested in continuing with this - otherwise I'm going to ask if there's someone else who would like to own it - and if not, then I'm going to propose that we close it. We can always reopen later if needed.

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Oct 18, 2018

@bnlong4417 on today's call Neil Avery & David Baldwin agreed to carry this forward - hope that's ok with you.

@longit644
Copy link
Copy Markdown
Author

@duglin My sincere apologies for the slow reply. I am very busy at the moment because our company is preparing for the important holiday sales this year and I forgot to catch this up. I'm totally ok with Avery & Baldwin to carry this forward, thank you for continuing to integrate Kafka into CloudEvents.

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Oct 19, 2018

@bnlong4417 no worries - thanks for getting back to us.... I was a little worried that you vanished :-)

@bluemonk3y
Copy link
Copy Markdown

bluemonk3y commented Oct 23, 2018

@duglin - I will have the follow-on PR available next week - I'm currently OOO - regards Neil

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Nov 1, 2018

Given #337 is ok to close this one?

@duglin
Copy link
Copy Markdown
Collaborator

duglin commented Nov 1, 2018

I'm going to assume we can close this due to #337 is now out there. I can reopen if someone things I jumped the gun.

@duglin duglin closed this Nov 1, 2018
duglin pushed a commit that referenced this pull request Jun 27, 2019
* Follow-on PR from #300

Kafka transport binding for CloudEvents, similar to the HTTP binding and proposed NATS, MQTT, AMQP bindings.

Signed-off-by: Neil Avery <neil@confluent.io>

* addressing remaining cloudEvent attribute names

Kafka transport binding for CloudEvents, similar to the HTTP binding and proposed NATS, MQTT, AMQP bindings.

Signed-off-by: Neil Avery <neil@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants