Giter Club home page Giter Club logo

Comments (19)

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

This one is invalid, since now the encoding/decoding is done manually in `cloudevents-json-jackson' module

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

Can you please explain in more detail how this is invalid? I don't understand.

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

Is there a cloudevents-json-jackson module this bug needs to be moved to?

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

The json jackson module still has the same issues. It should not use a custom ZonedDateTime Ser/DeSer and should properly handle the new JavaTimeModule stuff. This bug should not be closed.

https://github.com/cloudevents/sdk-java/tree/master/formats/json-jackson/src/main/java/io/cloudevents/format/json

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

It should not use a custom ZonedDateTime Ser/DeSer and should properly handle the new JavaTimeModule stuff

Can I ask the reason why the custom serde is not valid? The serialization/deserialization is handled correctly serializing/deserializing using RFC3339 (as underlined by the spec https://github.com/cloudevents/spec/blob/v1.0/spec.md#type-system). I've tried the JavaTimeModule but i found easier to just serialize/deserialize manually

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

I think we can remove these ones:

Since now they're not used anymore

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

@slinkydeveloper I'm not sure I understand what you mean "serialize/deserialize" manually? You are using Jackson so I need to be able to extend and put my own types and types from other libraries so they will serialize correctly like.

        .addModule(new JavaTimeModule())
        .addModule(new GuavaModule())
        .addModule(new HppcModule())
        .addModule(new PCollectionsModule())
        .addModule(new EclipseCollectionsModule())

Without JavaTimeModule I can't serialize the java 8 types related to time.
Instant, OffsetDateTime, LocalDateTime, etc...

Without the ability to add other modules like guava I can't serialize types from guava. I really need to be able to extend the Jackson configuration myself or else most POJOs will not be serializable.

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

If you're referring to the event payload, in the v2 of the sdk, the CloudEvent won't parse the event payload anymore, so you won't need to configure the integrated ObjectMapper because it's used just for the CloudEvent

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

So are you saying for unstructured i.e. application/json content type cloud events, the SDK v2 does not decode the body at all?

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

The sdk v2 decodes the event, but not the "data" field of the event: https://github.com/cloudevents/sdk-java/blob/master/api/src/main/java/io/cloudevents/CloudEvent.java#L45

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

you can take the byte array fro CloudEvent#getData and use jackson object mapper, jsonb, fast-json or whatever other library you like to go from data to your pojo

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

There is no data field in in unstructured/binary application/json cloud events the ”data” is the entire HTTP request body. Cloud event stuff is just in the headers in that case not the body. You are talking about structured application/cloudevents events.

https://github.com/cloudevents/spec/blob/master/http-protocol-binding.md#13-content-modes

https://github.com/cloudevents/spec/blob/master/spec.md#message

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

There is no data field in in unstructured/binary application/json cloud events the ”data” is the entire HTTP request body.

Ok maybe we misunderstood, but when you send the event in structured mode, encoded as json, there is a data field: https://github.com/cloudevents/spec/blob/v1.0/json-format.md#32-examples

Cloud event stuff is just in the headers in that case not the body

In binary mode, the body of the http envelope maps to the cloudevent data attribute, as explained https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#312-event-data-encoding

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

With latest changes, in both cases (binary/structured), the data field is handled transparently and served as binary array, that you can handle as you want

from sdk-java.

AceHack avatar AceHack commented on August 11, 2024

You can see in this code it is not, this is from the example. Your JSON decoder is used to decode the binary message into a Map.class

https://github.com/cloudevents/sdk-java/tree/master/api

/* Unmarshals as CloudEvent instance */
CloudEvent<AttributesImpl, Map> event =
  Unmarshallers.binary(Map.class)
    .withHeaders(() -> httpHeaders)
    .withPayload(() -> myPayload)
    .unmarshal();

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

I'm sorry but these examples are still not updated, look at the tests 😄

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

I reorganized a bit the READMEs, check it out!

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

Can we close this now?

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 11, 2024

I'm going to close it, reopen if you need it

from sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.