Archived

This forum has been archived. Please start a new discussion on GitHub.

Is it possible to use encapsulations in our own definitions

Is it possible to use Ice encapsulations in our own slice definitions? I have not found out how yet maybe I am just overlooking it.

Thanks

Comments

  • benoit
    benoit Rennes, France
    Hi,

    It's not clear to me what you mean by Ice encapsulations, can you detail a little more what you're looking for? Do you mean the protocol level encapsulations or encapsulation at the language level?

    Cheers,
    Benoit.
  • I am looking for a protocol level encapsulation i think.

    I would like to implement something similar to this:
    module my
    {
        struct MyMessage
        {
            string ID;
            string Description;
            Encapsulation OpaqueData;
        };
    
    };
    


    Is this considered at the protocol level and is this possible?
  • marc
    marc Florida
    You could certainly do this. The Encapsulation type would then be a sequence<Byte>. However, the question is why? Why do you want to throw away the type system, and add a protocol on top of the existing protocol? Why introduce your own IDs if proxies provide this for you? Why not send your request data as the desired type instead of sending the data as blob?
  • What we are doing is using Ice as the protocol over some queues and would like to use a single message type on the wire. In the encapsulations we are using other ice defined types. I guess if we had a union of some sort that would work. What do you recommened?

    I guess in original question didn't specify but what I was wondering if slice provided for the definitions of encapsulations?

    Thanks
  • marc
    marc Florida
    I'm afraid I don't really understand what you are trying to do. Why do you want to use a single message type? Why do you want to stuff the parameters into a blob, instead of sending the parameters simply as regular parameters?

    If you want to handle an Ice request as a blob, then you can do this with ice_invoke on the proxy, and Blobjects on the server side. This is how Glacier2 and IceStorm forward messages. Have a look at the Ice manual for more information, or at Mark's "Dynamic Ice" articles in issue 11 and issue 12 of Connections.
  • We are not using Ice interfaces. We are putting messages into a message queue. From that queue we send the messages through filter stacks a.k.a streams for processing.

    A process pulls messages from a queue and forwards them on to the streams. These streams either ignore the message, process the message and send it on or not. The payload in these messages has some common data but in some cases it has additional data specific to certain filters. I could use SOAP or some other dynamic "typesafe" messaging format on the queues but I would like a more efficient data representation because there will be just so much of it.

    The structure I presented is not representative of the process we are working on. We are actually migrating legacy IMS mainframe processes to open systems using open source frameworks and the queueing is a key component in integrating the legacy messaging systems with our new ones.
  • mes
    mes California
    Hi,

    It sounds like you need to use the streaming API that's discussed in the "Dynamic Ice" chapter of the manual. As Marc mentioned, the most recent issue of the newsletter contains an article I wrote that shows how to use this API.

    If possible, I recommend defining a Slice data type to represent each message. This has several advantages: transforming between an instance of the message type and a "blob" of bytes is very simple, it requires little code, and it is much less error-prone if the format changes later.

    Hope that helps,
    - Mark
  • This is exactly what I am doing, I was only asking if Slice had a native encapsulation definition that could be used. It is mentioned in the documentation that the protocol uses a definition and I just wanted to see if it was a public definition that could be used in our definitions.

    Thanks
  • No, there is no such keyword or built-in type as "Encapsulation". ("Encapsulation" is used for illustration purposes only in the protocol chapter.)

    An encapsulation is simply a byte count followed by the bytes in the encapsulation. So, the exact Slice equivalent is sequence<byte>.

    In case of the Ice protocol, encapsulations also contain an encoding version number. If you want to use that, the equivalent Slice definition would be
    sequence<byte> ByteSeq;
    struct Encapsulation
    {
        short major;
        short minor;
        ByteSeq bytes;
    };
    

    Cheers,

    Michi.
  • Thanks for all the help and I would like to say that Ice is by far one of the best products I have seen.