Wednesday, November 13, 2024

C# .NET client to publish 5 million events to Universal Messaging channel\IS Publishable document

In this blog article I have created a C# .NET client using Universal Messaging C# .NET API. This is in contrast to my previous two articles where I used Java and Message builders(as described in IBM official documentation) and Dynamic Builders to compose a Protobuf event and publish large amount of data to UM Channel\IS Publishable document. I took on the effort to do the same thing in C# to see if there will be a performance difference or if there is a different way to send messages to UM Channel more efficiently and to my surprise the performance metrics are so different between both implementations. I have described more in detail about the performance differences with same UM and IS setup in detail in the blog. Generate the C# code from the proto file. Below command is for running it from the same folder where the proto file is located.

This will generate a new cs file called SalesPdt.cs as show below.




At this point we have the auto generated csharp file generaed by the protoc compiler that we can import in to our existing solution and generate a nProtobufevent from the data and then loop over each generated event and publish to UM.

I have listed out a step-by-step instructions on how to implement a C# .NET program to generate a proto buf event and publish the event to UM. You can download the pdf document here.

For any questions or inquireies feel free to reach out to aarremreddy@silverspringtech.com

Program.cs










Sales.cs



UMUtilities.cs



Performance Metrics:
A first glance at the results show that it took less than half the time to publish 5 million records to UM from C# when compared with Java but if you drill down more in to the details it shows that the way we serialize and deserialize the messages is a lot different when using Descriptors\Builders from the library in comparison to using the auto generated code from protoc compiler. Having said that, I have not run a detailed performance test between Java and C# API’s to call out if one has a better performance than the other. One thing can be assured is that it was a lot easier for me to write the code in C# using the generated class instead of creating the Java code using the Descriptors and builders mentioned in the IBM documentation.

No comments:

Post a Comment