jdimeo edited a comment on issue #6889:
URL: https://github.com/apache/pulsar/issues/6889#issuecomment-887997379


   **EDIT:** Apologies. In my testing, I was using the same topic and so the 
schema was "locked in" to the previous schema before I introduced the custom 
`ObjectMapper`.  I can confirm that this method does work, though is a bit 
verbose and explodes your function .jar size since you need the client classes 
in there to leverage a custom schema (including stuff like Netty for byte 
buffers and stuff, strangely).  
   
   Original:
   
   @lhotari Something is still fishy, and I can't quite get to the bottom of 
it. I injected my own `ObjectMapper` using the `SchemaDefinitionBuilder` as 
recommended and I even confirmed it was being used with ugly logging in the 
function itself (using the new output  message builder to send a message):
   ```
   23:27:08.576 [public/default/fn] INFO  org...JacksonJsonWriter - WRITING 
MESSAGE WITH CORRECT OBJECT MAPPER 
{"id":"2052194","timestamp":"2021-03-31T19:30:17.344+00:00","action":"Update", 
...
   ```
   So the correct bytes are being generated (notably timestamps as UTC and 
using `@JsonValue` for the enum `action`).
   
   *However*, no matter *what* I do, I always get these bytes in the client:
   ```
   Cannot construct instance of `org...ChangeEvent$Action`, problem: UPDATE
    at [Source: 
(byte[])"{"id":"2052194","timestamp":1617219017344,"action":"UPDATE",
    ```
    Notably, the timestamps are back to ms since epoch and the enum is using 
the `name()`
    
    - I'm using the same schema in both my client test code and the function 
code
    - Even with a vanilla `ObjectMapper`, my enum is annotated with a 
`@JsonValue` for the title case "Update" - why is it being ignored?
    - Is something like gson or org.json getting in the way?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to