ā Looking for assistance in Deserializing Avro Binary stream
where the schema comes from the API and I dont have a static type
57 Replies
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Yea so basically salesforce went full stupid
And they EMBED an arvo payload inside a Protoc payload
lol
gRPC event works fine
Struggling with the Avro decoding
Let me dump some of my attempts here if you have a second to help
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Yea you're exactly right - the salesforce API DOES provide the schema
I just don't know how to use Arvo in C#
I have this
If you have any working code to dig up
I would be super duper appreciative
@tebeco
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Didn't know
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Nah 100% I get it
Thanks so much anyway
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
RIP
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Gahh Salesforce
WHY WOULD THEY DO THIS
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Yea
I'm passed that point
I have the schema in hand
And i have the payload in hand (Binary serialized)
And all i need is an example using Apache.Avro
Or any Avro library
To combine the two and get the data I need out of the payload in a decoded format
Within .NET C#
š
I have everything i need except good programming skills lol
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Lol this assumes that my Schema is bsaed on List<User>
As in I know before run time
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
I want to take the schema that salesforce gives
And use that
Which i know is possible
I just don't know how
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
I've tried all of these
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
This is likely to not work
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
So the Unary Channels i'm subbing too can change at any time
their schema
lol
Its the nature of salesforce itself
Hence why they provide a Schema
as a gRPC call
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Yea don't get me wrong - they've implemented this horribly
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Hmmmm
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Hmmmmmm
Ok
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
I think you've put me on the right track
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
I will assume the schema is not allowed to change
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
the goal is to allow users to subscribe to any object in salesforce
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
that emits an event on their event bus
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Wow
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
It is indeed
This is frustratingly easy to do in Python
lol
They have a java example too
And even easier in Javascript
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Pray and spray is completely acceptable
in this case
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
If it fails the user will be told
and they have to try again
Alright so using dynamic which I am extremely aware is unsafe
Can this be done and do you have a recommended library
Do i even need Avro?
I just want to decode the binary payload
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
I don't care what it actually is at all
The user is completely responsible for making sure the fields exist in the payload
Avro Binary Format Ā· Ambitious Systems
Avro specifies two serialization encodings: binary and JSON. Binary encoding is the default and used by most applications as it is smallerā¦
This looks like what I want
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
Hey
Because of you I got it working
I don't really know how to thank you enough š¦
public static string DecodeBinaryPayload(string schemaJson, byte[] payload)
{
var topicSchema = JsonToSchema(schemaJson);
using (var stream = new MemoryStream(payload))
{
var writer = new BinaryDecoder(stream);
var datum_reader = new Avro.Generic.GenericDatumReader<dynamic>(topicSchema, topicSchema);
var result = datum_reader.Read(stream, writer);
return "";
}
}
This does everything i need
If anyone needs this in the future
Unknown Userā¢2y ago
Message Not Public
Sign In & Join Server To View
EVEN MORE BETTERR
I cant tell you how happy i am now
š
ā¤ļø
ā¤ļø
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.