I am evaluating .NET Core 2.0 for IPC communication. I found that .NET Core does not support WCF on the server side. What can be used in .NET Core for inter-process communication along with callbacks (for publish-subscribe) model?
If you're ready to go low-level, you can use named pipes, but you'll have to implement publish/subscribe pattern yourself.
At a higher level, you can look into libraries like ZeroMQ/NetMQ - these are very thin layer on top of sockets with support of various patterns (like publish/subscribe).
Even higher level are true message queues - RabbitMQ.
And of course, the native way is Web API using ASP.NET Core.
I had a similar need but the existing solutions out there had too many dependencies for my liking and did not support proper two-way communication.
So I wrote the PipeMethodCalls package:
var pipeServer = new PipeServerWithCallback<IConcatenator, IAdder>(
new NetJsonPipeSerializer(),
"mypipe",
() => new Adder());
await pipeServer.WaitForConnectionAsync();
string concatResult = await pipeServer.InvokeAsync(c => c.Concatenate("a", "b"));
var pipeClient = new PipeClientWithCallback<IAdder, IConcatenator>(
new NetJsonPipeSerializer(),
"mypipe",
() => new Concatenator());
await pipeClient.ConnectAsync();
int result = await pipeClient.InvokeAsync(a => a.AddNumbers(4, 7));
It serializes the method name and arguments as JSON or MessagePack, invokes it on the other side, then packages the response to send back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With