Skip to content

Plen-wang/rabbitmqclient

Repository files navigation

rabbitmqclient

rabbitmq .net client

接受消息

private static void Listening()
        {
            RabbitMqClient.Instance.ActionEventMessage += mqClient_ActionEventMessage;
            RabbitMqClient.Instance.OnListening();
        }

        private static void mqClient_ActionEventMessage(EventMessageResult result)
        {
            if (result.EventMessageBytes.EventMessageMarkcode == MessageTypeConst.ZgUpdatePurchaseStatus)
            {
                var message =
                    MessageSerializerFactory.CreateMessageSerializerInstance()
                        .Deserialize<UpdatePurchaseOrderStatusByBillIdMqContract>(result.MessageBytes);

                result.IsOperationOk = true; //处理成功

                Console.WriteLine(message.ModifiedBy);
            }
        }

发送消息


private static void SendEventMessage()
        {
            for (var i = 1; i < 10000; i++)
            {
                var originObject = new UpdatePurchaseOrderStatusByBillIdMqContract()
                {
                    UpdatePurchaseOrderStatusType = 1,
                    RelationBillType = 10,
                    RelationBillId = 10016779,
                    UpdateStatus = 30,
                    ModifiedBy = i
                };

                var sendMessage =
                    EventMessageFactory.CreateEventMessageInstance(originObject, MessageTypeConst.ZgUpdatePurchaseStatus);

                RabbitMqClient.Instance.TriggerEventMessage(sendMessage, "CMQ.Purchase", "CMQ.Purchase");

                Console.WriteLine(i);
            }
        }

About

rabbitmq .net client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages