Joe,
I've made some nice progress with this - what a valuable tool you've created.
I'm still experiencing some behavior that I don't understand and would appreciate any thoughts you might have.
I'm using a proxy object created as such:
var myObj = java.newProxy(interfaceType) to create a new callback object into node. So I pass this object as a param into a function that sets this object as the callback interface
so, as we discussed, this works great but after getting the call back several times I get an error that it has lost the object and that I need to be using ref() and unref() - I see that this is an exception generated in your c code (util iirc). so I tried to set the myObj.ref() or even var holderRef = myObj.ref() before I send the object to java to be set as the callback but I have the same behavior (errs out after 8-10 callbacks) so I finally got it to work by adding the code myObj.ref() inside the callback itself. This behavior doesn't quite make sense to my - why do I need to reinform the JNI side to keep the reference this frequently - and not sure why it works for the first 8-10 calls before it fails - is there some default setting in the jni layer that is getting autodecremented each time a call to a proxy object is called? This kinda seems like a bug to me - e.g. I can understand needing to manage my own reference on the js side but it seems like the reference should live indefinitely until I release it by calling myObj.unref(). So I should be able to increment the ref() before I set it as the callback then when I'm done, I just decrement the ref count with .unref() and if thats the last reference it should release the proxy object during normal gc. Maybe my thinking is wrong on this but anyway let me know what you think or how I should be thinking about it.
So a different but similar problem is that the node app is exiting immediately - is there a way to inform node that there is an active background process (like you have when you start an httplistener) and that it should continue to run until we release and/or close the object? the instantiation of the java object is static and shouldn't hold the app open but as long as I hold reference to a java object created I would think the app should continue to run.
one last thing I'm experiencing is a weird timing/synchronization problem where messages will come into the java bridge in order yet will fire the callback out of order - is there anything you can think of that might explain this? For the time being I believe I can work around this by requiring explicitly acknowledgements back to the server which will insure that each record is processed by the client before the server will send the next - but there is a performance impact for this so would prefer to not have to use the explicit ack feature and since I can confirm the messages hit the java side in order it seems reasonable that we should be able to insure they hit node in order too. A lot of what I'm doing is calculating trajectory, momentum, etc so messages out of order is a significant problem.
and, for the record, using your lib, I now have a working bidirectional interface between node.js and a jms broker using the brokers out of box jms client jar file and the little bridge app is dynamically loading the jms connectionFactory object so with this you should be able to use it with any jms provider - you have to add the jms lib to the classpath and then pass the name/loc of the jms jar file and then it should work - i've tested this with TIBCO EMS and with Apache ActiveMQ - will try another or two as time is available. Once I get it settled a bit more I'll post the code - I might make this another node lib available in npm - node-jms maybe.