In my original post on Java interop with MSMQ, I gave a sample implementation of a Queue class for Java that was able to send and receive strings, and I suggested that it would be pretty simple to extend it to send whatever you want. A couple of people have asked just what would be required, so here are some additional details.
For example, suppose you want to extend the Queue class to be able to send and receive a byte array. Here's what you'd do:
First, Read The Fine Manual from Sun on sending arrays through JNI. Then, using the newly-acquired knowledge from that page, add a couple of new native methods (one for send, one for receive) in the MsmqQueueNativeMethods.cpp file, that handle a jbyteArray as input instead of a jstring. Then expose those native methods in the Queue.java class, following the example set by the jstring methods. Re-build, you're done.
I've heard back from one person that this works.
If you aren't so comfortable with JNI, a simpler approach may be just to base64-encode the byte array into a string, on the sender and on the receiver side. This would require only Java programming. But of course you would need a base64 encoding class, which is not included in the Java base class library, as far as I know. I think Apache have one. Anyone?