Beispiel #1
0
        public void PublishMediaJob([FromBody] bool poisonQueue)
        {
            string settingKey = Constants.AppSettingKey.MediaJobNotificationStorageQueueName;
            string queueName  = AppSetting.GetValue(settingKey);

            if (poisonQueue)
            {
                queueName = string.Concat(queueName, Constants.Storage.Queue.PoisonSuffix);
            }
            string               messageId, popReceipt;
            MessageClient        messageClient   = new MessageClient();
            string               queueMessage    = messageClient.GetMessage(queueName, out messageId, out popReceipt);
            MediaJobNotification jobNotification = Newtonsoft.Json.JsonConvert.DeserializeObject <MediaJobNotification>(queueMessage);

            if (jobNotification != null)
            {
                MediaClient.PublishJob(jobNotification, false);
                messageClient.DeleteMessage(queueName, messageId, popReceipt);
            }
        }
Beispiel #2
0
 public IActionResult Index([FromServices] MessageClient messageClient, string category)
 {
     return(View(messageClient.GetMessage(category)));
 }
Beispiel #3
0
    //static void Connect(String server)
    //{
    //    try
    //    {
    //        // Create a TcpClient.
    //        // Note, for this client to work you need to have a TcpServer
    //        // connected to the same address as specified by the server, port
    //        // combination.
    //        Int32 port = 11000;
    //        TcpClient client = new TcpClient(server, port);
    //        BinaryFormatter _bFormatter = new BinaryFormatter();

    //        // 1-3
    //        List<string> dblist = new List<string>();
    //        for (int i = 1; i < 4; i++)
    //        {
    //            string dbname = String.Format("DB_{0}", i);
    //            dblist.Add(dbname);
    //        }

    //        // Translate the passed message into ASCII and store it as a Byte array.
    //        //Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);

    //        // send a message to trigger 3 database traffic
    //        Message dbMessage = GetMessage(dblist);
    //        _bFormatter.Serialize(client.GetStream(), dbMessage);

    //        Console.ReadLine();
    //        dblist.Clear();

    //        // send another  4-9    6 dbs
    //        for (int i = 4; i < 10; i++)
    //        {
    //            string dbname = String.Format("DB_{0}", i);
    //            dblist.Add(dbname);
    //        }
    //         dbMessage = GetMessage(dblist);
    //        _bFormatter.Serialize(client.GetStream(), dbMessage);
    //        // Send the message to the connected TcpServer.
    //        //stream.Write(data, 0, data.Length);



    //        Console.ReadKey();
    //        // close all traffic
    //        Message opMessage = GetMessage("Close");
    //        _bFormatter.Serialize(client.GetStream(), opMessage);

    //        Console.ReadKey();

    //        // Receive the TcpServer.response.

    //        // Buffer to store the response bytes.
    //        //data = new Byte[256];

    //        // String to store the response ASCII representation.
    //        //String responseData = String.Empty;

    //        // Read the first batch of the TcpServer response bytes.
    //        //Int32 bytes = stream.Read(data, 0, data.Length);
    //        //responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);

    //        //List<string> receivedDBList = (List<String>)_bFormatter.Deserialize(client.GetStream());
    //        //if (receivedDBList != null)
    //        //{
    //        //    Console.WriteLine("Received: {0}", receivedDBList);
    //        //}

    //        // signal server to close this connection
    //        opMessage = GetMessage("Close");
    //        _bFormatter.Serialize(client.GetStream(), opMessage);
    //        client.Close();

    //}
    //    catch (ArgumentNullException e)
    //    {
    //        Console.WriteLine("ArgumentNullException: {0}", e);
    //    }
    //    catch (SocketException e)
    //    {
    //        Console.WriteLine("SocketException: {0}", e);
    //    }

    //    Console.WriteLine("\n Press Enter to continue...");
    //    Console.Read();
    //}



    public static int Main(String[] args)
    {
        Console.WriteLine("Entry point");
        MessageClient mclient = new MessageClient(11000);

        mclient.Setup();
        Console.WriteLine("complete connection");
        Console.ReadLine();
        List <string> dblist = new List <string>();

        for (int i = 1; i < 3; i++)
        {
            string dbname = String.Format("DB_{0}", i);
            dblist.Add(dbname);
        }
        Message dbMessage = mclient.GetMessage(dblist);

        mclient.SendMessageToServer("zeche-traffic1", dbMessage);

        Console.ReadLine();
        dblist.Clear();

        for (int i = 3; i < 5; i++)
        {
            string dbname = String.Format("DB_{0}", i);
            dblist.Add(dbname);
        }
        dbMessage = mclient.GetMessage(dblist);
        mclient.SendMessageToServer("zeche-traffic2", dbMessage);

        Console.ReadLine();
        dblist.Clear();

        for (int i = 5; i < 8; i++)
        {
            string dbname = String.Format("DB_{0}", i);
            dblist.Add(dbname);
        }
        dbMessage = mclient.GetMessage(dblist);
        mclient.SendMessageToServer("zeche-traffic1", dbMessage);

        Console.ReadLine();
        dblist.Clear();


        // send another  4-9    6 dbs
        for (int i = 8; i < 10; i++)
        {
            string dbname = String.Format("DB_{0}", i);
            dblist.Add(dbname);
        }
        dbMessage = mclient.GetMessage(dblist);
        mclient.SendMessageToServer("zeche-traffic2", dbMessage);

        Console.ReadLine();
        mclient.Close();



        return(0);
    }