Ejemplo n.º 1
0
        private void SendTestMessageToInboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                InboundQueueNameTextBox.Text,
                InboundQueueSendSasTokenTextBox.Text);

            var systemProperties = new JObject
            {
                ["CorrelationId"] = Guid.NewGuid().ToString()
            };

            var body = new JObject
            {
                ["CallType"] = "Command",
                ["Uri"]      = "/api/component/Office.CombinedCeilingLights/status"
            };

            var content = new JObject
            {
                ["action"] = "nextState"
            };

            body["Content"] = content;

            Task.Run(async() => await queueSender.SendAsync(systemProperties, body));
        }
Ejemplo n.º 2
0
        public MessageProducerProvider(string appCode, string metaServer, MessageStore messageStore)
        {
            if (appCode == null || appCode.Length == 0)
            {
                throw new ArgumentException("appCode未配置");
            }

            Logger.Info("Start Constructor");
            try
            {
                if (Interlocked.Increment(ref _instanceCount) > 1)
                {
                    Logger.Warn("WARNING: MessageProducerProvider这个类很重,请确保在一个进程中创建[少量]的实例,严禁在服务的请求中创建实例。如果你确定你的用法没有问题可以忽略该错误日志");
                }

                _appCode            = appCode;
                _metaServer         = metaServer;
                _idGenerator        = new TimestampIdGenerator();
                _brokerGroupService = new BrokerGroupService(appCode, metaServer);
                Logger.Info("idGenerator inited");
                _sender = new QueueSender(_brokerGroupService);
                _store  = messageStore;
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "MessageProducerProvider Constructor error");
                throw;
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        static void FlushEvents(object state)
        {
            if (QueueSender == null && DocumentsAPIConfiguration != null)
            {
                QueueSender = new QueueSender(DocumentsAPIConfiguration);
            }

            var batch = new List <EventBase>();

            if (QueueSender != null)
            {
                while (Events.TryTake(out var result))
                {
                    batch.Add(result);

                    if (batch.Count > BATCH_ENQUEUE_SIZE)
                    {
                        QueueSender.SendEventAsync <EventBase>(batch).Wait();
                        batch.Clear();
                    }
                }
            }

            if (batch.Any())
            {
                QueueSender.SendEventAsync <EventBase>(batch).Wait();
            }
        }
Ejemplo n.º 4
0
        private void AddNewItem2()
        {
            var qs = new QueueSender();

            while (true)
            {
                _count++;

                TodoItem item = new TodoItem()
                {
                    Name      = $"Item {_count}",
                    Completed = false,
                    DueDate   = DateTime.Now,
                    UserName  = "******"
                };

                Message m = new Message()
                {
                    Operation = Operation.Add, Item = item
                };

                qs.Send(m);

                Console.WriteLine("Sent item.");
                Console.ReadKey();
            }
        }
Ejemplo n.º 5
0
    internal csQueueSender(string[] args)
    {
        ParseArgs(args);

#if _NET_20
        try {
            tibemsUtilities.initSSLParams(serverUrl, args);
        }
        catch (Exception e)
        {
            System.Console.WriteLine("Exception: " + e.Message);
            System.Console.WriteLine(e.StackTrace);
            System.Environment.Exit(-1);
        }
#endif
        if (data.Count == 0)
        {
            Console.Error.WriteLine("Error: must specify at least one message text");
            usage();
        }

        Console.WriteLine("\n------------------------------------------------------------------------");
        Console.WriteLine("csQueueSender SAMPLE");
        Console.WriteLine("------------------------------------------------------------------------");
        Console.WriteLine("Server....................... " + ((serverUrl != null)?serverUrl:"localhost"));
        Console.WriteLine("User......................... " + ((userName != null)?userName:"******"));
        Console.WriteLine("Queue........................ " + queueName);
        Console.WriteLine("------------------------------------------------------------------------\n");

        try {
            QueueConnectionFactory factory = new TIBCO.EMS.QueueConnectionFactory(serverUrl);

            QueueConnection connection = factory.CreateQueueConnection(userName, password);

            QueueSession session = connection.CreateQueueSession(false, Session.AUTO_ACKNOWLEDGE);

            /*
             * Use createQueue() to enable sending into dynamic queues.
             */
            TIBCO.EMS.Queue queue = session.CreateQueue(queueName);

            QueueSender sender = session.CreateSender(queue);

            /* publish messages */
            for (int i = 0; i < data.Count; i++)
            {
                TextMessage message = session.CreateTextMessage();
                string      text    = (string)data[i];
                message.Text = text;
                sender.Send(message);
                Console.WriteLine("Sent message: " + text);
            }

            connection.Close();
        } catch (EMSException e) {
            Console.Error.WriteLine(e.StackTrace);
            Environment.Exit(0);
        }
    }
 public BlockchainController(IConfiguration config,
                             ILogger <BlockchainController> logger,
                             QueueSender queueSender,
                             TransactionBroadcastManager transactionBroadcastManager,
                             BlockchainService blockchainService)
 {
     this.config      = config;
     this.logger      = logger;
     this.queueSender = queueSender;
     this.transactionBroadcastManager = transactionBroadcastManager;
     this.blockchainService           = blockchainService;
 }
Ejemplo n.º 7
0
 public BlockchainService(IConfiguration config,
                          ILogger <BlockchainService> logger,
                          AzureServiceBusManager serviceBusManager,
                          QueueSender queueSender,
                          BlockchainRepository blockchainRepository)
 {
     this.config               = config;
     this.logger               = logger;
     this.serviceBusManger     = serviceBusManager;
     this.queueSender          = queueSender;
     this.blockchainRepository = blockchainRepository;
 }
Ejemplo n.º 8
0
        private void SendTestMessageToOutboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                OutboundQueueNameTextBox.Text,
                OutboundQueueSendSasTokenTextBox.Text);

            var properties = new JsonObject();
            var body       = new JsonObject();

            Task.Run(async() => await queueSender.SendAsync(properties, body));
        }
Ejemplo n.º 9
0
    public void OnMessage(Message msg)
    {
        try
        {
            TextMessage textMsg = (TextMessage)msg;
            Console.WriteLine("Received message: " + textMsg.Text);
            if (textMsg.Text.Contains("Stop deploying bus"))
            {
                Console.WriteLine(name + ": Buses deployment has been stopped");
            }
            else
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(textMsg.Text);
                string  xPathString = "//busRequest/station";
                XmlNode station     = doc.DocumentElement.SelectSingleNode(xPathString);
                Console.WriteLine(name + ": Buses have been dispatched to {0}", station.InnerText);
            }
        }
        catch (Exception e)
        {
            Console.Error.WriteLine("Unexpected exception message callback!");
            Console.Error.WriteLine(e.StackTrace);
            Environment.Exit(-1);
        }

        try {
            QueueConnectionFactory factory    = new TIBCO.EMS.QueueConnectionFactory(serverUrl);
            QueueConnection        connection = factory.CreateQueueConnection(userName, password);
            QueueSession           session    = connection.CreateQueueSession(false, Session.AUTO_ACKNOWLEDGE);

            /*
             * Use createQueue() to enable sending into dynamic queues.
             */
            String          queueName = "q.deployed";
            TIBCO.EMS.Queue queue     = session.CreateQueue(queueName);
            QueueSender     sender    = session.CreateSender(queue);

            /* publish messages */
            // TextMessage message = session.CreateTextMessage();
            // message.Text = "yolo";
            // sender.Send(message);
            // Console.WriteLine("Sent message: "+text);

            connection.Close();
        } catch (EMSException e) {
            Console.Error.WriteLine(e.StackTrace);
            Environment.Exit(0);
        }
    }
Ejemplo n.º 10
0
        private static async Task AwakeReceive(string queueName, Type type)
        {
            var collection = new ServiceCollection();

            collection.AddScoped <ICustomerService, CustomerService>();
            collection.AddScoped <ICustomerRepository, CustomerEntityFrameworkRepository>();

            var serviceProvider = collection.BuildServiceProvider();
            var service         = serviceProvider.GetService <ICustomerService>();

            var queueSender = new QueueSender(service);

            await queueSender.Receive(queueName, type);
        }
Ejemplo n.º 11
0
 public CallbackController(
     DocumentsAPIConfiguration documentsAPIConfiguration,
     QueueSender queueSender,
     IFileStore fileStore,
     FileContentsService fileContentsService,
     ISecurityContext securityContext
     ) : base(securityContext)
 {
     this.DocumentsAPIConfiguration = documentsAPIConfiguration;
     this.QueueSender         = queueSender;
     this.FileStore           = fileStore;
     this.FileContentsService = fileContentsService;
     this.SecurityContext     = securityContext;
 }
Ejemplo n.º 12
0
 public void TestSender()
 {
     log.Debug("New QueueSender...");
     //
     this.sender             = new QueueSender();
     this.sender.BrokerURL   = BROKER;
     this.sender.Destination = QUEUE_NAME;
     this.sender.Start();
     log.Debug("Send Messages...");
     for (int i = 0; i < 20; i++)
     {
         this.sender.SendMessage(string.Format("Message #{0}", i + 1));
     }
 }
Ejemplo n.º 13
0
        public void Enqueue_EnqueueCalledInQueueWrapper()
        {
            var factory      = new Mock <IQueueFactory>();
            var queueWrapper = new Mock <IQueueWrapper>();

            factory.Setup(x => x.CreateSender(QueueSettings.QueueName)).Returns(queueWrapper.Object);
            var queueReceiver = new QueueSender(factory.Object);
            var mail          = new Mail();

            queueReceiver.Enqueue(mail);

            factory.Verify(x => x.CreateSender(QueueSettings.QueueName));
            queueWrapper.Verify(x => x.Enqueue(QueueSettings.QueueName, mail));
            Assert.True(true);
        }
Ejemplo n.º 14
0
        private static async Task AwakeReceive(string queueName, Type type)
        {
            var collection = new ServiceCollection();

            collection.AddScoped <IRentService, RentService>();
            collection.AddScoped <IRentItemService, RentItemService>();
            collection.AddScoped <IRentRepository, RentEntityFrameworkRepository>();
            collection.AddScoped <IRentItemRepository, RentItemEntityFrameworkRepository>();

            var serviceProvider = collection.BuildServiceProvider();
            var serviceRent     = serviceProvider.GetService <IRentService>();
            var serviceRentItem = serviceProvider.GetService <IRentItemService>();

            var queueSender = new QueueSender(serviceRent, serviceRentItem);

            await queueSender.Receive(queueName, type);
        }
Ejemplo n.º 15
0
 public void TestSender()
 {
     log.Debug("New QueueSender...");
     //
     this.sender             = new QueueSender();
     this.sender.BrokerURL   = BROKER;
     this.sender.Destination = QUEUE_NAME;
     this.sender.Start();
     log.Debug("Send Messages...");
     for (int i = 0; i < 20; i++)
     {
         this.sender.SendMessage(string.Format("Message #{0}", i + 1));
     }
     //log.Debug("receive message...");
     //while (this.receiver.Process())
     //{ }
     //log.Debug("exit from receive....");
 }
Ejemplo n.º 16
0
        private void SendTestMessageToInboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                InboundQueueNameTextBox.Text,
                InboundQueueSendSasTokenTextBox.Text);

            var systemProperties = new JsonObject();

            systemProperties.SetNamedValue("CorrelationId", JsonValue.CreateStringValue(Guid.NewGuid().ToString()));

            var body = new JsonObject();

            body.SetNamedValue("CallType", JsonValue.CreateStringValue("Command"));
            body.SetNamedValue("Uri", JsonValue.CreateStringValue("/api/component/Office.CombinedCeilingLights/status"));

            var content = new JsonObject();

            content.SetNamedValue("action", JsonValue.CreateStringValue("nextState"));

            body.SetNamedValue("Content", content);

            Task.Run(async() => await queueSender.SendAsync(systemProperties, body));
        }
Ejemplo n.º 17
0
 public ItemsController()
 {
     _dbProvider = new CosmosDbProvider();
     _queue      = new QueueSender();
 }
Ejemplo n.º 18
0
        public void Create(CustomerViewModel CustomerViewModel)
        {
            CreateCustomerCommand createCustomerCommand = new CreateCustomerCommand(_mapper.Map <Customer>(CustomerViewModel));

            QueueSender.Send(createCustomerCommand);
        }
Ejemplo n.º 19
0
        private QueueSender StartSending(string sendQueueName)
        {
            Console.WriteLine("SENDER: Initializing...");
            var sender = new QueueSender(this.connection, this.senderCount, this.senderDelay, sendQueueName);

            Console.WriteLine("SENDER: Initialized. Now sending.");
            return sender;
        }
Ejemplo n.º 20
0
        public void Delete(Guid id)
        {
            DeleteCustomerCommand deleteCustomerCommand = new DeleteCustomerCommand(id);

            QueueSender.Send(deleteCustomerCommand);
        }
Ejemplo n.º 21
0
 public QueueController(QueueSender queueSender, ISecurityContext securityContext)
     : base(securityContext)
 {
     QueueSender = queueSender;
 }
Ejemplo n.º 22
0
 public PakjesController(PakjesContext context, ILogger <PakjesController> logger, QueueSender queueSender)
 {
     _context     = context;
     _logger      = logger;
     _queueSender = queueSender;
 }
Ejemplo n.º 23
0
        public void Create(VendorViewModel vendorViewModel)
        {
            CreateVendorCommand createVendorCommand = new CreateVendorCommand(_mapper.Map <Vendor>(vendorViewModel));

            QueueSender.Send(createVendorCommand);
        }
Ejemplo n.º 24
0
        public void Update(CustomerViewModel CustomerViewModel)
        {
            UpdateCustomerCommand updateCustomerCommand = new UpdateCustomerCommand(_mapper.Map <Customer>(CustomerViewModel));

            QueueSender.Send(updateCustomerCommand);
        }
Ejemplo n.º 25
0
 public ScraperClient(ScraperConfig config)
 {
     _config    = config;
     _queue     = new QueueSender(config.QueueHost, config.QueueName);
     _instagram = new InstagramClient();
 }
Ejemplo n.º 26
0
        public void Update(RentItemViewModel RentItemViewModel)
        {
            UpdateRentItemCommand updateRentItemCommand = new UpdateRentItemCommand(_mapper.Map <RentItem>(RentItemViewModel));

            QueueSender.Send(updateRentItemCommand);
        }
Ejemplo n.º 27
0
        public void Update(VendorViewModel vendorViewModel)
        {
            UpdateVendorCommand updateVendorCommand = new UpdateVendorCommand(_mapper.Map <Vendor>(vendorViewModel));

            QueueSender.Send(updateVendorCommand);
        }
Ejemplo n.º 28
0
        public void Create(RentItemViewModel RentItemViewModel)
        {
            CreateRentCommand createRentCommand = new CreateRentCommand(_mapper.Map <Rent>(RentItemViewModel));

            QueueSender.Send(createRentCommand);
        }
Ejemplo n.º 29
0
        public void Delete(Guid id)
        {
            DeleteRentItemCommand deleteRentItemCommand = new DeleteRentItemCommand(id);

            QueueSender.Send(deleteRentItemCommand);
        }
Ejemplo n.º 30
0
 public GivingPromoCodeToCustomerNotifier(QueueSender queueSender)
 {
     _queueSender = queueSender;
 }
Ejemplo n.º 31
0
 public AdministrationNotifier(QueueSender queueSender)
 {
     _queueSender = queueSender;
 }