Use messages with dynamic objects
See original GitHub issueI wanted to pass some message through grpc with dynamic data, something like this:
public class Message
{
// some other properties
...
public object Payload { get; set; }
}
If I understood right (not sure), in protobuf it could be done with “Any”, something like this:
import "google/protobuf/any.proto";
message Message {
google.protobuf.Any payload = 1;
}
How can I pack/unpack some object to this “Any” type and vice-versa? For some reason Protobuf c# documentation only shows examples with java and c++ https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/well-known-types/any As a workaround I could just pass some json in this payload, but then I would lose performance by performing two different serializations. Thank you for the help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Guide Page
This section explores sending automated SMS messages using Microsoft Dynamics CRM/365 workflows. Go to "Settings" and Select "Processes". Press New to create a ......
Read more >Obtain dynamic object in MassTransit consumer
We use an empty marker interface for a group of events that need to be saved to some audit log database. However, in...
Read more >Java Tip 71: Use dynamic messaging in Java
This article explains how dynamic messaging can be easily used and how it can be ... The java.lang.reflect package defines wrapper objects for...
Read more >Introduction to Dynamic Objects
Dynamically assign properties to the instance. Send messages to instances of the class using the pre-defined methods defined for the Class.
Read more >Personalize campaign messages with dynamic links and ...
Dynamic links let you personalize text messages with personalized links to ... Dynamic links or variables added to a message use the object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. Or just a string field with JSON. Or a bytes field if the dynamic payload is binary.
I don’t know your system or your performance requirements. Measure and find out.
btw, there are now docs about how to work with unstructured data - https://docs.microsoft.com/en-us/aspnet/core/grpc/protobuf?view=aspnetcore-6.0#unstructured-and-conditional-messages