问题
I have an ultra-low latency program and need to interface with a Windows COM component. What would be the fastest way to do this? Using a COM bridge like JACOB or write a native COM library and send out messages using a messaging bus like ZeroMQ?
回答1:
If you use ZeroMQ, you'll be dealing with two processes. And passing a message from one process to another is more expensive than doing the same within the same process. So using a Java COM bridge will certainly result in a lower latency.
Having said that, it's however only relevant if you're dealing with extermely low latency. If your COM component already has a latency several times higher than inter process message passing (e.g. because it is receiving and forwarding messages over a network or performing expensive computations), then either option will be okay because they both have a marginal effect on the overall latency.
Note that JACOB doesn't support all COM components, only those with a COM automation interface. So you might need to use a different Java COM bridge such as JCom.
来源:https://stackoverflow.com/questions/7298056/java-com-bridge