Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 02-02-2010
jharriot jharriot is offline
Registered User
 
Name: John Harriott
Organization: BAE Systems
Project: P3 Mid Life Upgrade
 
Join Date: Mar 2007
Posts: 11
Dispatching legacy C++ messages via Ice

I have a legacy C++ single threaded application that receives messages over sockets and deserialises each message payload into its corresponding C++ class object. The class objects are then dispatched to various modules within the program.

I now want to modify the program to be either multithreaded or multi-process. If I go multi-process I need a mechanism to dispatch messages to each process. If I use Ice I could replicate all the message definitions as Ice (there are quite a lot of messages), or can I simply send the existing message object as a blob of bytes and let the receiving end typecast the blob back to the message? What Ice mechanism could I use to exchange message blobs? Are there issues with sending classes over the wire as blobs?

Regards John
Reply With Quote
  #2 (permalink)  
Old 02-03-2010
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,928
Hi John,

You can just use a sequence of bytes "in" param to transmit your serialized data:

Code:
// Slice

sequence<byte> ByteSeq;

interface MyIntf
{
    void op1(ByteSeq param);
};
Your application will be responsible for serializing/de-serializing the data. The drawback with using such blobs in the Slice is the loss of type-safety at the Slice level and the fact that it's not easily portable to another language (if you used Slice types to encode your classes, portability to other language mappings would come at no cost). This is probably fine for your application however.

Note that Ice for Java and C# provide a Slice serialize metadata which allows to pass Java/C# native types directly to the Slice generated code (proxies/servants). The generated code, under the hood, takes care of the serialization to or from the byte sequence. This is possible because Java and C# both provide standard APIs for serialization. In C++, this is currently not possible, mostly because there are no standard serialization APIs (but this is something which could be added).

So if you have a large number of classes and want to reduce the boiler plate code to serialize/de-serialize your classes to/from the byte sequence, an option would be to implement something similar to Java/C#. You could directly pass your native classes to the Slice generated code and have the generated code take care of the serialization/de-serialization. For an example on how this metadata could work, see the Java and C# demo/Ice/serialize in your Ice 3.4b distribution. If you are interested in sponsoring such a feature, please contact us at info@zeroc.com

Cheers,
Benoit.
Reply With Quote
  #3 (permalink)  
Old 02-03-2010
mefoster mefoster is offline
Registered User
 
Name: Mary Ellen Foster
Organization: Heriot-Watt University, Edinburgh
Project: ECHOES learning environment
 
Join Date: Jun 2006
Posts: 111
Is the serialization metadata for Java new in 3.4b? I've never noticed it before ... very cool.

MEF
__________________
Mary Ellen Foster
Reply With Quote
  #4 (permalink)  
Old 02-03-2010
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,928
It's not new, it was added with Ice 3.3.1, see Ice 3.3.1 RELEASE_NOTES.

Cheers,
Benoit.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ObjectFactory for connecting to legacy classes? moli Help Center 1 01-17-2010 06:07 PM
Linking ICE/C++ to a legacy C program pjtait Help Center 1 04-23-2009 09:07 AM
ICE user exception messages chris Help Center 1 01-31-2005 07:31 AM
Exception messages panic Comments 0 10-19-2004 04:33 AM
ServantLocator and dispatching thread ganzuoni Help Center 8 07-10-2003 12:38 PM


All times are GMT -4. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2009 ZeroC, Inc.