Comments (19)
This one is invalid, since now the encoding/decoding is done manually in `cloudevents-json-jackson' module
from sdk-java.
Can you please explain in more detail how this is invalid? I don't understand.
from sdk-java.
Is there a cloudevents-json-jackson module this bug needs to be moved to?
from sdk-java.
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.
from sdk-java.
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.
I think we can remove these ones:
- https://github.com/cloudevents/sdk-java/blob/master/formats/json-jackson/src/main/java/io/cloudevents/format/json/ZonedDateTimeDeserializer.java
- https://github.com/cloudevents/sdk-java/blob/master/formats/json-jackson/src/main/java/io/cloudevents/format/json/ZonedDateTimeSerializer.java
Since now they're not used anymore
from sdk-java.
@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.
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.
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.
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.
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.
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.
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.
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.
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.
I'm sorry but these examples are still not updated, look at the tests 😄
from sdk-java.
I reorganized a bit the READMEs, check it out!
from sdk-java.
Can we close this now?
from sdk-java.
I'm going to close it, reopen if you need it
from sdk-java.
Related Issues (20)
- Optimize BaseCloudEvent#readExtensions method
- Support for JDK 17 needed for cloudevents library HOT 9
- An occasional problem:Unable to load implementation class JsonFormat HOT 1
- Add RocketMQ into the 'status' section of README.md HOT 1
- BaseCloudEvent.getExtensionNames() breaks cloud event encapsulation HOT 2
- Add benchmarks to CloudEvents SQL HOT 1
- Does CloudEventDeserializer deserialize custom extensions (kafka headers)? HOT 3
- CVE-2022-42004 - Update jackson version HOT 3
- Spring Webflux: example not working HOT 2
- Custom validation for context attributes in wrapper library HOT 1
- can't setup `cloudevents.serializer.event_format` in quarkus HOT 3
- How to transport List<CloudEvent> between Springboot services by openfeign?
- Running into exception while using cloudevent values in kafka streams HOT 1
- Enhancement: generalise the validation in wrapper library HOT 4
- Change type of source attribute from URI to String HOT 2
- Add support for spring-amqp HOT 1
- Contribution question for wrapper for RabbitmQ and Redis HOT 8
- Port tck tests once the CESQL spec stabilizes more HOT 1
- Error assembling JAR: Invalid automatic module name: '' HOT 1
- Cannot invoke "java.lang.ClassLoader.getParent()" because "this.currentLoader" is null
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-java.