Vendor: ISC

Type: encode

Description: A simple message type for enacpsulating data in other generic formats for transport across SIE.

  • "type" (enum) - One of TEXT, JSON, YAML, MSGPACK, or XML

  • "payload" (bytes) - A payload of the described type.

      /* nmsg/isc/encode.proto */
      package nmsg.isc;
      enum EncodeType {
          TEXT = 0;
          JSON = 1;
          YAML = 2;
          MSGPACK = 3;
          XML = 4;
      message Encode {
          required EncodeType type = 1;
          required bytes      payload = 2;

Below is a Python coding example for reading "ISC:encode" messages off the wire and printing them out. For XML, it requires that you have the appropriate hooks to decode the XML schema received.

    #!/usr/bin/env python
    # (found in pynmsg/examples of nmsg distribution)

    import sys

    import nmsg

    class UnsupportedEncodeType(Exception):

    class Encode(object):
        __slots__ = ('encode', 'decode')
        def __init__(self, encode, decode):
            self.encode = encode
            self.decode = decode

    class EncodeDummy(object):
        def encode(*args, **kwargs):
            raise UnsupportedEncodeType
        def decode(*args, **kwargs):
            raise UnsupportedEncodeType

        import json
        encode_json = Encode(json.dumps, json.loads)
    except ImportError:
        encode_json = EncodeDummy

        import yaml
        encode_yaml = Encode(yaml.dump, yaml.load)
    except ImportError:
        encode_yaml = EncodeDummy

        import msgpack
        encode_msgpack = Encode(msgpack.dumps, msgpack.loads)
    except ImportError:
        encode_msgpack = EncodeDummy

    table_encode = {
        'TEXT':     Encode(str, str),
        'JSON':     encode_json,
        'YAML':     encode_yaml,
        'MSGPACK':  encode_msgpack,
        'XML':      EncodeDummy

    def process(m):
        nmsg.print_nmsg_header(m, sys.stdout)
        sys.stdout.write('type: %s\n' % m['type'])
        if m['type'] in table_encode:
                sys.stdout.write('payload: %s' % table_encode[m['type']].decode(m['payload']))
            except UnsupportedEncodeType:
                sys.stdout.write('payload: <UNABLE TO DECODE>')
            sys.stdout.write('payload: <UNKNOWN ENCODING>')

    def main(addr, port):
        i = nmsg.input.open_sock(addr, port)
        sys.stdout.write('listening on %s/%s\n' % (addr, port))
        while True:
            m =
            if m:

    if __name__ == '__main__':
        if len(sys.argv) == 3:
            main(sys.argv[1], int(sys.argv[2]))
        elif len(sys.argv) == 1:
            main('', 9430)
            sys.stderr.write('Usage: %s [<ADDR> <PORT>]\n' % sys.argv[0])