Пример #1
0
    public static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: SimpleDequeuer <qspace> <qname>");
            Environment.Exit(1);
        }

        string qSpace = args[0];
        string qName  = args[1];

        ATMI.tpinit(null);
        try
        {
            ByteBuffer data = ATMI.tpalloc("STRING", null, 512);
            try
            {
                TPQCTL ctl = new TPQCTL();
                ctl.flags = ATMI.TPQWAIT;
                int len;
                ATMI.tpdequeue(qSpace, qName, ctl, ref data, out len, 0);
                string message = StringUtils.ReadStringBuffer(data, len);
                Console.WriteLine("Dequeued '" + message + "' from " + qSpace + "." + qName);
            }
            finally
            {
                ATMI.tpfree(data);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Пример #2
0
    public static void Main(string[] args)
    {
        if ((args.Length < 3) || (args.Length > 4))
        {
            Console.WriteLine("Usage: SimpleEnqueuer <qspace> <qname> <message> [<replyq>]");
            Environment.Exit(1);
        }

        string qSpace  = args[0];
        string qName   = args[1];
        string message = args[2];
        string replyQ  = (args.Length < 4) ? null : args[3];

        ATMI.tpinit(null);
        try
        {
            ByteBuffer data = StringUtils.NewStringBuffer(message);
            try
            {
                TPQCTL ctl = new TPQCTL();
                ctl.flags = ATMI.TPNOFLAGS;
                if (replyQ != null)
                {
                    ctl.flags      = ctl.flags | ATMI.TPQREPLYQ;
                    ctl.replyqueue = replyQ;
                }
                ATMI.tpenqueue(qSpace, qName, ctl, data, 0, 0);
                Console.WriteLine("Enqueued '" + message + "' in " + qSpace + "." + qName);
            }
            finally
            {
                ATMI.tpfree(data);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Пример #3
0
 internal static extern int tpdequeue(
     [MarshalAs(UnmanagedType.LPStr)] string qspace,
     [MarshalAs(UnmanagedType.LPStr)] string qname,
     [In, Out] TPQCTL ctl, ref IntPtr data, out int len, int flags);