< Back to Blogs
Java with half-and-half by admin on April 18, 2006 05:03PM

I got the chance to spend an hour this week with Dr. Wayne Citrin, CTO of JNBridge. He’s been refining a Java/.NET interoperability product for the last five years – starting out with a risky bet on .NET when it was only in Beta. Back then I was at BEA Systems, we tried to use jCOM as a bridge to Microsoft applications that customers needed to integrate with J2EE systems. There were reliability and configuration challenges with this approach, and we found that as .NET grew in our customer base, we could only advise them to use Web Services for interoperability.

WS for interoperability is a good choice when you can build well-defined contracts between systems and coarse-grained, loosely coupled integration is acceptable (despite the performance and reliability impacts). There are situations where tightly-coupled integration is necessary (specific security requirements; chatty communications), which is where I’d apply a product like JNBridge.

JNBridge handles the conversion of Java objects into .NET objects and vice versa – including management of references on both sides to ensure that object extent is handled correctly, and converting “by reference” and “by value” situations to their correct native implementation. I’m simplifying for brevity, but for more detail you can take a look here.

They have 3 modes of operation – XML/HTTP, Binary/TCP, and Shared Memory (for running on the same server). As we proceeded through the discussion, I was interested in how they dealt with the “complex object” issue, where a Java object contains other objects by reference.

When converting complex objects to Web Services, the antipattern is to marshal the entire object graph into a SOAP message, add getters and setters to the remote proxy that handle write-backs. This causes problems both in communication overhead and performance (that’s a lot of data to marshal to XML; plus this marshalling will happen every time the remote client needs to update a field in the complex object). There are other problems that I won’t get into here.

For these situations, it can work better to have a tightly-coupled integration layer – with JNBridge, you could use their Binary/TCP mode to have a conversion from Java to .NET objects happening on the J2EE server, and communicating with the .NET tier through native .NET remoting.

Another common interop request I hear from software architects is to have BizTalk or .NET interop with JMS (Java Message Service). This is an area that I haven’t seen great solutions to in the past. The best approach from performance and reliability standpoint should result from a tightly-coupled integration at the JMS Client layer; here I would consider deploying JNBridge in Shared Memory mode, with .NET application logic on the same machine as JNBridge and a JMS Client, which would remotely access a JMS Cluster via RMI or your Java protocol of choice.

Now if only Java were associated with Guinness we could call this approach a “Black-and-Tan”… as it is I’ll have to leave it “Half-and-half”.

Comments RSS
  1. aperson said:

    Aside from the tcp object passing with remoting instead of web services,

    http://www.ikvm.net/userguide/intro.html

    What is the difference between JNBridge and IVKM?

    IKVM works natively in monodevelop including the latest version with the gui designer. It also works with both .NET and mono.

    What is the advantage of this commerical product?

    Is it IDL binding code over a tcp stream between .NET and Java proceedures? That can be done by other means. Not poking, just a question.

    posted at 08:53PM 04/18/2006
  2. anotherperson said:

    Aside from the tcp object passing with remoting instead of web services,

    http://www.ikvm.net/userguide/intro.html

    What is the difference between JNBridge and IKVM?

    IKVM works natively in monodevelop including the latest version with the gui designer. It also works with both .NET and mono.

    What is the advantage of this commerical product?

    Is it IDL binding code over a tcp stream between .NET and Java proceedures? That can be done by other means. Not poking, just a question.

    posted at 08:55PM 04/18/2006
  3. Hi Sam --

    Thanks for the kind words.

    To answer the question about how JNBridgePro differs from IKVM -- IKVM (a very cool tool) translates Java bytecodes to .NET binaries.  This allows the Java code to call the .NET code (it's all CIL), and vice versa.  JNBridgePro, on the other hand, keeps the Java running in a JVM and the .NET running in a CLR and bridges the two -- we feel that this helps to guarantee conformant behavior on both sides.  Also, JNBridgePro supports a much wider set of architectures (Java and .NET in the same process, in separate processes on the same machine, or on different machines).  IKVM only supports the Java and .NET in the same process.  Finally, IKVM is tied to the GNU Classpath library (which may not be appropriate for everyone), while JNBridgePro will work with any JVM past JDK 1.3.1.  So there are good uses for both tools, but I think JNBridgePro covers a wider set of scenarios.

    As for the last question, JNBridgePro doesn't use IDL and doesn't depend on tcp streams, although it can use them.  I'd recommend going to our Web site to see a more detailed discussion of the underlying architecture, and the features of the product.  If there are more questions about it, I'd be happy to answer them here.

    posted at 10:02PM 04/18/2006
  4. aperson said:

    It looks like a closed RPC, that has been reimplemented via shared mem, IPC, then again via tcp stream and soap.

    Sort of like COM or Corba, except you say it doesn't have any IDL so other languages and compilers can interface it.

    People that buy this have to trust your company alot too. If it comes down to a presentation day and there is a bug in your glue, there's no fixing it. Just like Stallman and his printer at MIT.

    posted at 11:13PM 04/18/2006
  5. I've found that really the best balance in the last near-decade has been CORBA. It's complex and overengineered, but it handles things like remote complex objects easily, is (relatively) high performance, and can interop with just about anything. Java supports it well.

    It does require formal bindings and tighter coupling, but this tends to improve reliability and better design.

    Short of CORBA, the next best thing I've found for interop that actually gets things done quickly is raw HTTP or XMLRPC.  Sounds like this would be a good step in providing a simpler out of the box mechanism for this kind of complex work.  This would be great - the XMLRPC layer is simple, but the APIs and libraries are fragmented and messy to support.

    Got a Linux path in the works, of any kind? A native version wouldn't be necessary, but a means of injecting data from a remote Linux system would be a huge benefit.

    posted at 10:10AM 04/19/2006
  6. There are .NET/CORBA bridges out there.  One of the things we've found, though, is that customers usually don't want to access CORBA-accessible objects; they're looking to access legacy Java classes and objects that can't be accessed through CORBA (usually the source isn't available, so they couldn't make the changes to make the objects CORBA-accessible even if they wanted to), so a CORBA bridging solution isn't an option.

    HTTP and XMLRPC can work in some cases, but there are performance issues, not to mention issues in passing around remote references, and in mapping betweeen Java classes and .NET classes.

    posted at 12:00PM 04/19/2006
  7. Sam Ramji said:

    Actually, I covered the XML option in the first part of the post.  You would select a technology like JNBridge when Web Services/XML/REST won't meet your performance needs (typically the XML marshalling and unmarshalling for chatty applications) or your security needs.

    CORBA is quite challenging to secure and true interoperability between ORBs is something I've yet to see as a real occurrence.  The overall scenario we're discussing here is not "what is the best distributed object model" but "how do I get the distributed object models I'm using to interoperate" which is why this is focused on .NET and Java.

    posted at 01:58PM 04/19/2006
  8. davehod said:

    You can do .Net/JMS today for JBoss using this

    http://sourceforge.net/projects/csil/

    posted at 11:45AM 04/20/2006

  9. >CORBA is quite challenging to secure and true interoperability between
    > ORBs is something I've yet to see as a real occurrence.  The overall
    > scenario we're discussing here is not "what is the best distributed
    > object model" but "how do I get the distributed object models I'm
    > using to interoperate" which is why this is focused on .NET and Java.

    Thanks for the clarification - I muddled the two: In this area it
    seems that usually the "best" is the one that's actually able to
    interoperate.  CORBA interops well at the cost of extremely tight
    coupling, and it's rare any more that you have full control of
    everything in the stack.  (Unless you're DoD)

    This definitely sounds interesting, though. Is there a Linux
    bridge,or a recommended stepping stone to get to this?

    posted at 12:23PM 04/20/2006
  10. Two other bridging products worth mentioning:

    J-Integra for .NET (Java /.NET)
    http://j-integra.intrinsyc.com/products/net/

    J-Integra Espresso (Corba/RMI-IIOP/.NET)
    http://j-integra.intrinsyc.com/products/espresso/

    The .NET product is basically the same as Wayne's fore mentioned JNBridge.  This product does run under linux since it is a pure java implementation of Microsoft's .NET remoting.  Basically, its a 3rd party bridge for Microsoft's remoting technology.  

    The Espresso product is a largely a Corba ORB written in pure managed .NET which does in fact run under linux/mono.  Since all major Application Servers communicate with RMI/IIOP this product can interact with EJB's using a native protocol with extremely high performance.

    Both products are currently under a $100 dollars for a client license.

    posted at 07:18PM 05/02/2006
Post a Comment
*
*