|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Java and C++ Message Interoperability |
« View previous topic :: View next topic » |
Author |
Message
|
skytorch |
Posted: Tue Nov 12, 2002 1:51 pm Post subject: Java and C++ Message Interoperability |
|
|
 Apprentice
Joined: 10 Jun 2002 Posts: 47 Location: New York City
|
Hi,
Does anyone have this experience ? If you've a C structure like this:
struct User {
char* name;
int id;
char* address;
}
A C app send a msg with data content in this structure. how do you get it from Java MQMessage API. is it represented as a Java Object imbeded in the MQMessage ? If so, what's the Java representation of this C struct ?
Also, if you've a java object imbeded in a MQMessage sent by a Java application to a queue like this:
class Firm {
String name;
String location;
int employees;
public String getName();
}
How do you get this info in your C application that is retrieving messages from this same queue ?
Thanks.
Sky |
|
Back to top |
|
 |
bduncan |
Posted: Tue Nov 12, 2002 2:02 pm Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
MQ issues with this aside, you can't take a C struct and magically turn it into a java object and vice versa. You will have to create a scheme to convert each of these language specific data structures into some string of characters, send this across the network via MQSeries, and write a parser on the other end that can reconstruct the data structure in the appropriate language. I had to do this before myself. I had a perl application sending an MQ message to a C application. I wrote a perl routine which took a perl hash (which may contain nested hashes) and turn the whole thing into a string. Then I wrote a parser in C to turn this into a corresponding struct. You'll have to employ the same technique, unless someone out there has taken the time to write a general toolkit to go between java and C... I'm guessing someone has already written a routine in C which can take a serialized java object and turn it into some C data structure... But I don't know about the other way around... _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
skytorch |
Posted: Wed Nov 13, 2002 8:00 am Post subject: |
|
|
 Apprentice
Joined: 10 Jun 2002 Posts: 47 Location: New York City
|
Ooch. That hurts.
Since MQ already takes care of the platform differences, i.e. you can exchange MQ messages between different platforms without worrying about platform details (such as big endian, etc), why MQ doesn't take care of the language differences, or at least take care of mappings between priliminary types of different languages ??
For example, if I need to send a int in Java to C app or send a float in C to Java app, what do I have to do ? Do I have to convert it to String or convert it to MSLong (or other related MQ types) ? Or I don't have to do anything, MQ will take care of this mapping ??
What's a good solution here ? Thanks a lot.
Sky |
|
Back to top |
|
 |
bduncan |
Posted: Wed Nov 13, 2002 11:47 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
No. MQSeries does nothing. It is simply a transport mechanism. There is no transformation of the message at all (aside from character set conversions). If you are looking for some shrink wrapped solution you need to look to WMQI. Otherwise, you'll have to do what I mentioned earlier. You'll notice that when you retrieve a message in C, the message contents are always a character array. Regardless of what got put in on the other end. You as the designer may know that this character array is really an int, so you can cast it as such, but for complex data structures, there is no simple way to return them to their original state, as the implementation of the datastructure (array, stack, object, etc) vary widely depending not only on the platform but the language that you are using. _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|