For Programmers: Free Programming Magazines  


Home > Archive > Java Help > August 2006 > passing an jobject through message queue









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author passing an jobject through message queue
rohith

2006-08-23, 4:02 am

i want to send an object from from one JVM to another through message
queue. for that i wrote a JNI program which takes an jobject as a
parameter. now i want to pass this object to another native code throgh
message queue.

struct mesg{
int type;
jobject sendobj;
};

JNIEXPORT void JNICALL Java_server_share(JNIEnv *env,jobject obj,
jobject sendobj)
{
struct mesg m;
m.sendobj=sendobj;
int ser_mq=CreateMQ();
WritetoQue(ser_mq);
}

when i run the program, the server program run without any errors. But
at the client side i am not able to call the class of the object
received.

JNIEXPORT jobject JNICALL Java_client_share(JNIEnv *env,jobject obj)
{
int mqid = create();
struct mesg que=readfromque(mqid);
jobject robj=que.recvobj;
jclass cls2=(*env)->GetObjectClass(env,robj);/* ERROR*/
return robj;
}

neither i could use the received object(return robj) to retrieve its
field.

Is there any way to send a jobject from one C code to another through
message queue or any other IPC mechanisms?
Any help is much appreciated...

Gordon Beaton

2006-08-23, 4:02 am

On 22 Aug 2006 22:20:54 -0700, rohith wrote:
> i want to send an object from from one JVM to another through
> message queue. for that i wrote a JNI program which takes an jobject
> as a parameter. now i want to pass this object to another native
> code throgh message queue.


You can't send the object reference "as is" through a message queue.
Try serializing it to a byte array first.

/gordon

--
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com