简体   繁体   English

在Java应用程序和基于C#的插件之间建立IPC链接

[英]Establishing IPC link between a Java app and C#-based plugins

We have a Java app, as well as a number of C#-based plugins for other apps (eg Excel) that can communicate with the main app. 我们有一个Java应用程序,以及许多可以与主应用程序通信的其他应用程序(例如Excel)的基于C#的插件。 The communications layer is implemented using Apache MINA on the Java side and xsd for the .NET plugins. 使用Java端的Apache MINA和.NET插件的xsd来实现通信层。 Typically things run on the same (Windows) machine, though it would be better not to assume that (eg, allow the main app to run on a Mac and be able to communicate with Excel on a different machine). 通常情况下,事情运行在同一台(Windows)计算机上,尽管最好不要假设(例如,允许主应用程序在Mac上运行,并能够在另一台计算机上与Excel通信)。

The communication has to work regardless of whether the main app or the plugin(s) start up first. 无论是首先启动主应用程序还是插件,通信都必须正常进行。 My question is how best to establish the link? 我的问题是如何最好地建立链接? Currently, our main Java app listens on a port that the plugins constantly poll for availability. 当前,我们的主要Java应用程序侦听插件不断轮询的端口的可用性。 This is obviously wasteful and inelegant. 这显然是浪费和微不足道的。 But it works. 但这有效。

An alternative would be to have each plugin listening on its own port, and when the app starts up it sends a "Hello" kind of message to each known port (on localhost), and then have the plugins establish the link at that point. 一种替代方法是让每个插件都在其自己的端口上侦听,并且在应用程序启动时,它会向每个已知端口(在localhost上)发送“ Hello”类型的消息,然后让插件在该位置建立链接。

I've also looked a bit at multicast, but don't really know much about it. 我也看了一下多播,但对它并不太了解。 And of course, there could be multiple users on the same subnet all using the app. 当然,同一子网上可能有多个用户都在使用该应用程序。

Any other ideas or thoughts? 还有其他想法或想法吗?

You should not be concerned with wasted attempts to connect to the server - it is not a resource intensive operation and the plugin requires the connection to work. 您不必担心会浪费连接服务器的尝试-这不是资源密集型操作,并且插件需要连接才能工作。 There does not seems to be any real motivation to use anything different from a traditional client/server approach which you already are doing. 似乎没有任何真正动机去使用与您已经在做的传统客户端/服务器方法不同的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM