Esempio n. 1
0
        public static void SendReplyMessage(TIBCO.EMS.Message msg, TIBCO.EMS.Queue ReplyQueue, ref Session session)
        {
            try
            {
                TIBCO.EMS.MessageProducer producer = session.CreateProducer(ReplyQueue);

                producer.Send(msg);
            }
            catch (EMSException e) { throw e; }
        }
Esempio n. 2
0
        public static void  SendMessage(TIBCO.EMS.Message msg, TIBCO.EMS.Queue queue)

        {
            try
            {
                Session session = Messaging.EMS.Connection.EMSQueueConnection.connection.CreateSession(false, Session.CLIENT_ACKNOWLEDGE);

                TIBCO.EMS.MessageProducer producer = session.CreateProducer(queue);

                producer.Send(msg);
            }
            catch (EMSException e)


            { throw e; }
        }
    public csMsgProducer(String[] args)
    {
        ParseArgs(args);

        try {
            tibemsUtilities.initSSLParams(serverUrl,args);
        }
        catch (Exception e)
        {
            System.Console.WriteLine("Exception: "+e.Message);
            System.Console.WriteLine(e.StackTrace);
            System.Environment.Exit(-1);
        }

        Console.WriteLine("\n------------------------------------------------------------------------");
        Console.WriteLine("csMsgProducer SAMPLE");
        Console.WriteLine("------------------------------------------------------------------------");
        Console.WriteLine("Server....................... " + ((serverUrl != null)?serverUrl:"localhost"));
        Console.WriteLine("User......................... " + ((userName != null)?userName:"******"));
        Console.WriteLine("Destination.................. " + name);
        Console.WriteLine("Send Asynchronously.......... " + useAsync);
        Console.WriteLine("Message Text................. ");

        for (int i = 0; i < data.Count; i++)
        {
            Console.WriteLine(data[i]);
        }
        Console.WriteLine("------------------------------------------------------------------------\n");

        try
        {
            TextMessage msg;
            int i;

            if (data.Count == 0)
            {
                Console.Error.WriteLine("Error: must specify at least one message text\n");
                Usage();
            }

            Console.WriteLine("Publishing to destination '" + name + "'\n");

            ConnectionFactory factory = new TIBCO.EMS.ConnectionFactory(serverUrl);

            connection = factory.CreateConnection(userName, password);

            // create the session
            session = connection.CreateSession(false, Session.AUTO_ACKNOWLEDGE);

            // create the destination
            if (useTopic)
                destination = session.CreateTopic(name);
            else
                destination = session.CreateQueue(name);

            // create the producer
            msgProducer = session.CreateProducer(null);

            if (useAsync)
                completionListener = new EMSCompletionListener();

            // publish messages
            for (i = 0; i < data.Count; i++)
            {
                // create text message
                msg = session.CreateTextMessage();

                // set message text
                msg.Text = (String) data[i];

                // publish message
                if (useAsync)
                    msgProducer.Send(destination, msg, completionListener);
                else
                    msgProducer.Send(destination, msg);

                Console.WriteLine("Published message: " + data[i]);
            }

            // close the connection
            connection.Close();
        }
        catch (EMSException e)
        {
            Console.Error.WriteLine("Exception in csMsgProducer: " + e.Message);
            Console.Error.WriteLine(e.StackTrace);
            Environment.Exit(-1);
        }
    }