private static void testPubhlishAndSubscribeOneMsg( BroadCastService broadCastService , BroadCastServiceClient broadCastServiceClient, String queueName , String data,String bindingKey ) { Console.WriteLine("\n"); /* Publishing single message on the queue */ broadCastService.publishData(queueName, data, bindingKey); /* Getting the first message from the queue */ BasicDeliverEventArgs basicDeliverEventArgs = broadCastServiceClient.subscribeFirstMessage(queueName, bindingKey, 100); var message1 = Encoding.UTF8.GetString(((BasicDeliverEventArgs)basicDeliverEventArgs).Body); var routingKey1 = ((BasicDeliverEventArgs)basicDeliverEventArgs).RoutingKey; Console.WriteLine(" Received Msg: '{0}' key :{1} on Queue :{2}", message1, routingKey1, queueName); /* removing one queue from amqp server*/ broadCastServiceClient.clearQueue(queueName); }
private static void testPubhlishAndSubscribeOneMsg(BroadCastService broadCastService , BroadCastServiceClient broadCastServiceClient, String queueName , String data, String bindingKey) { Console.WriteLine("\n"); /* Publishing single message on the queue */ broadCastService.publishData(queueName, data, bindingKey); /* Getting the first message from the queue */ BasicDeliverEventArgs basicDeliverEventArgs = broadCastServiceClient.subscribeFirstMessage(queueName, bindingKey, 100); var message1 = Encoding.UTF8.GetString(((BasicDeliverEventArgs)basicDeliverEventArgs).Body); var routingKey1 = ((BasicDeliverEventArgs)basicDeliverEventArgs).RoutingKey; Console.WriteLine(" Received Msg: '{0}' key :{1} on Queue :{2}", message1, routingKey1, queueName); /* removing one queue from amqp server*/ broadCastServiceClient.clearQueue(queueName); }
private static void testPubhlishAndSubscribeAllMsg(BroadCastService broadCastService , BroadCastServiceClient broadCastServiceClient, String queueName , String data, String bindingKey, int limit) { /* Publishing mulitple message on the queue */ for (int i = 0; i < limit; i++) { data = System.Environment.MachineName + " " + new DateTime().Date + " " + i; broadCastService.publishData(queueName + i, data + "-0", bindingKey + i); broadCastService.publishData(queueName + i, data + "-1", bindingKey + i); broadCastService.publishData(queueName + i, data + "-2", bindingKey + i); broadCastService.publishData(queueName + i, data + "-3", bindingKey + i); broadCastService.publishData(queueName + i, data + "-4", bindingKey + i); broadCastService.publishData(queueName + i, data + "-5", bindingKey + i); } /* Getting the all message from the queue */ for (int i = 0; i < limit; i++) { Console.WriteLine("\n"); List <BasicDeliverEventArgs> listData = broadCastServiceClient.subscribeAllData(queueName + i, bindingKey + i, 100); for (int j = 0; j < listData.Count; j++) { object ea = (BasicDeliverEventArgs)listData[j]; var message = Encoding.UTF8.GetString(((BasicDeliverEventArgs)ea).Body); var routingKey = ((BasicDeliverEventArgs)ea).RoutingKey; Console.WriteLine(" Received Msg: '{0}' key :{1} on Queue :{2}", message, routingKey, queueName + i); } } /* removing all the queue from amqp server*/ Console.WriteLine("\n"); for (int i = 0; i < limit; i++) { broadCastServiceClient.clearQueue(queueName + i); Console.WriteLine("Deleting Queue '{0}'", queueName + i); } }
private static void testPubhlishAndSubscribeAllMsg(BroadCastService broadCastService , BroadCastServiceClient broadCastServiceClient, String queueName , String data, String bindingKey, int limit) { /* Publishing mulitple message on the queue */ for (int i = 0; i < limit; i++) { data = System.Environment.MachineName + " " + new DateTime().Date + " " + i; broadCastService.publishData(queueName + i, data + "-0", bindingKey + i); broadCastService.publishData(queueName + i, data + "-1", bindingKey + i); broadCastService.publishData(queueName + i, data + "-2", bindingKey + i); broadCastService.publishData(queueName + i, data + "-3", bindingKey + i); broadCastService.publishData(queueName + i, data + "-4", bindingKey + i); broadCastService.publishData(queueName + i, data + "-5", bindingKey + i); } /* Getting the all message from the queue */ for (int i = 0; i < limit; i++) { Console.WriteLine("\n"); List<BasicDeliverEventArgs> listData = broadCastServiceClient.subscribeAllData(queueName + i, bindingKey + i, 100); for (int j = 0; j < listData.Count; j++) { object ea = (BasicDeliverEventArgs)listData[j]; var message = Encoding.UTF8.GetString(((BasicDeliverEventArgs)ea).Body); var routingKey = ((BasicDeliverEventArgs)ea).RoutingKey; Console.WriteLine(" Received Msg: '{0}' key :{1} on Queue :{2}", message, routingKey, queueName + i); } } /* removing all the queue from amqp server*/ Console.WriteLine("\n"); for (int i = 0; i < limit; i++) { broadCastServiceClient.clearQueue(queueName + i); Console.WriteLine("Deleting Queue '{0}'", queueName + i); } }