You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pulsar.apache.org by Sijie Guo <gu...@gmail.com> on 2018/08/08 17:41:55 UTC

Re: Marshaling polymorphic objects

On Wed, Aug 8, 2018 at 9:05 AM Schaffert, Lowell <lo...@lmco.com>
wrote:

> I need to be able to encode and decode a polymorphic enum of which there
> are 5 concrete implementations.


>
> My issue is that:
>
>
> AvroSchema class does not allow access to the org.apache.avro.Schema
> schema which is necessary to create unions.


We shaded avro dependency to avoid conflicts with any application
dependencies. That is for allowing people to use its Avro version. so you
can include the Avro dependency in your application and use that to compile
and generate your object.


>
>
> JSONSchema class does not allow access to
> com.fasterxml.jackson.databind.ObjectMapper objectMapper which provides the
> fine grain control of encoding/decoding of objects.
>

Same reason as avro. You don't need to use the dependency used by Pulsar.
You can include jackson dependency in your application and use that for
generating json objects.


Let me know if that makes sense to you.

- Sijie




>
>
> Does anyone have an suggestions as to how I can proceed?
>
> Lowell
>
>
>

Re: EXTERNAL: Re: Marshaling polymorphic objects

Posted by Sijie Guo <gu...@gmail.com>.
No. I meant to use Pulsar schema. However you don't need to use the avro
dependencies introduced by pulsar since those dependencies are shaded. You
can include both pulsar-client and avro dependency
in your application, then you will use the version of Avro you include.

I've put up an example on how to use Avro schema.

https://github.com/sijie/pulsar-avro-schema-example

Feel free to check it out. Let me know if you have any questions.

- Sijie


On Wed, Aug 8, 2018 at 11:47 AM Schaffert, Lowell <lo...@lmco.com>
wrote:

> Are you saying that I should just not use
> org.apache.pulsar.client.api.Schema and just encode/decode the object
> myself and pass it as a string to Pulsar thus bypassing the Pulsar schema
> registry?
>
> Lowell
>
>
>
> ________________________________
> From: Sijie Guo <gu...@gmail.com>
> Sent: Wednesday, August 8, 2018 11:41:55 AM
> To: users@pulsar.incubator.apache.org
> Subject: EXTERNAL: Re: Marshaling polymorphic objects
>
>
>
> On Wed, Aug 8, 2018 at 9:05 AM Schaffert, Lowell <
> lowell.schaffert@lmco.com<ma...@lmco.com>> wrote:
> I need to be able to encode and decode a polymorphic enum of which there
> are 5 concrete implementations.
>
>
> My issue is that:
>
>
> AvroSchema class does not allow access to the org.apache.avro.Schema
> schema which is necessary to create unions.
>
> We shaded avro dependency to avoid conflicts with any application
> dependencies. That is for allowing people to use its Avro version. so you
> can include the Avro dependency in your application and use that to compile
> and generate your object.
>
>
>
> JSONSchema class does not allow access to
> com.fasterxml.jackson.databind.ObjectMapper objectMapper which provides the
> fine grain control of encoding/decoding of objects.
>
> Same reason as avro. You don't need to use the dependency used by Pulsar.
> You can include jackson dependency in your application and use that for
> generating json objects.
>
>
> Let me know if that makes sense to you.
>
> - Sijie
>
>
>
>
>
> Does anyone have an suggestions as to how I can proceed?
>
> Lowell
>
>
>

Re: EXTERNAL: Re: Marshaling polymorphic objects

Posted by "Schaffert, Lowell" <lo...@lmco.com>.
Are you saying that I should just not use org.apache.pulsar.client.api.Schema and just encode/decode the object myself and pass it as a string to Pulsar thus bypassing the Pulsar schema registry?

Lowell



________________________________
From: Sijie Guo <gu...@gmail.com>
Sent: Wednesday, August 8, 2018 11:41:55 AM
To: users@pulsar.incubator.apache.org
Subject: EXTERNAL: Re: Marshaling polymorphic objects



On Wed, Aug 8, 2018 at 9:05 AM Schaffert, Lowell <lo...@lmco.com>> wrote:
I need to be able to encode and decode a polymorphic enum of which there are 5 concrete implementations.


My issue is that:


AvroSchema class does not allow access to the org.apache.avro.Schema schema which is necessary to create unions.

We shaded avro dependency to avoid conflicts with any application dependencies. That is for allowing people to use its Avro version. so you can include the Avro dependency in your application and use that to compile and generate your object.



JSONSchema class does not allow access to com.fasterxml.jackson.databind.ObjectMapper objectMapper which provides the fine grain control of encoding/decoding of objects.

Same reason as avro. You don't need to use the dependency used by Pulsar. You can include jackson dependency in your application and use that for generating json objects.


Let me know if that makes sense to you.

- Sijie





Does anyone have an suggestions as to how I can proceed?

Lowell