Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 840
Arun Avatar asked Jun 08 '17 16:06

Arun


2 Answers

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.

like image 153
Igor Labutin Avatar answered Sep 23 '22 22:09

Igor Labutin


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.

like image 42
RandomEngy Avatar answered Sep 26 '22 22:09

RandomEngy