Results 1 to 4 of 4

Thread: Dispatching legacy C++ messages via Ice

  1. #1
    jharriot is offline Registered User
    Name: John Harriott
    Organization: BAE Systems
    Project: P3 Mid Life Upgrade
    Join Date
    Mar 2007
    Posts
    30

    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

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,140
    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.

  3. #3
    mefoster is offline Registered User
    Name: Mary Ellen Foster
    Organization: Heriot-Watt University, Edinburgh
    Project: ECHOES learning environment
    Join Date
    Jun 2006
    Posts
    118
    Is the serialization metadata for Java new in 3.4b? I've never noticed it before ... very cool.

    MEF

  4. #4
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,140
    It's not new, it was added with Ice 3.3.1, see Ice 3.3.1 RELEASE_NOTES.

    Cheers,
    Benoit.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Missing error messages in ICE v3.4.1.
    By Gravitas in forum Bug Reports
    Replies: 0
    Last Post: 03-09-2011, 06:06 AM
  2. Replies: 1
    Last Post: 01-17-2010, 07:07 PM
  3. Linking ICE/C++ to a legacy C program
    By pjtait in forum Help Center
    Replies: 1
    Last Post: 04-23-2009, 10:07 AM
  4. ICE user exception messages
    By chris in forum Help Center
    Replies: 1
    Last Post: 01-31-2005, 08:31 AM
  5. ServantLocator and dispatching thread
    By ganzuoni in forum Help Center
    Replies: 8
    Last Post: 07-10-2003, 01:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •