ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Java and C++ Message Interoperability

Post new topic  Reply to topic
 Java and C++ Message Interoperability « View previous topic :: View next topic » 
Author Message
skytorch
PostPosted: Tue Nov 12, 2002 1:51 pm    Post subject: Java and C++ Message Interoperability Reply with quote

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
View user's profile Send private message
bduncan
PostPosted: Tue Nov 12, 2002 2:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
skytorch
PostPosted: Wed Nov 13, 2002 8:00 am    Post subject: Reply with quote

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
View user's profile Send private message
bduncan
PostPosted: Wed Nov 13, 2002 11:47 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Java and C++ Message Interoperability
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.