'IPC using .NET Core that supports duplex channel or callbacks

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?



Solution 1:[1]

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.

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pang
Solution 2