예제 #1
0
        public Task <HttpResponseMessage> GetBigImage(BigImage bigImage)
        {
            ResponseBase <string> response = new ResponseBase <string>();

            try
            {
                UploadFileObj uploadFileObj = new UploadFileObj()
                {
                    MsgId          = bigImage.MsgId,
                    MsgType        = 3,
                    WxId           = bigImage.WxId,
                    ToWxId         = bigImage.ToWxId,
                    LongDataLength = bigImage.LongDataLength,
                };
                string mchId = RedisCache.CreateInstance().Get(ConstCacheKey.GetMchIdKey(uploadFileObj.WxId));
                if (string.IsNullOrEmpty(mchId))
                {
                    throw new Exception("未初始化商户Ip");
                }
                string objName = $"{FileStorageHelper.GetObjectName(mchId)}{uploadFileObj.MsgId}.png";

                var     producer = RocketMqHelper.CreateDefaultMQProducer(MqConst.UploadOssProducerGroup);
                var     buffer   = Encoding.UTF8.GetBytes(uploadFileObj.ToJson());
                Message message  = new Message(MqConst.UploadOssTopic, buffer);
                producer.SendMessage(message);



                response.Data = objName;
            }
            catch (ExpiredException ex)
            {
                response.Success = false;
                response.Code    = "401";
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Code    = "500";
                response.Message = ex.Message;
            }
            return(response.ToHttpResponseAsync());
        }
예제 #2
0
        public ConsumeConcurrentlyStatus consumeMessage(List list, ConsumeConcurrentlyContext ccc)
        {
            Iterator iterator = list.iterator();

            while (iterator.hasNext())
            {
                try
                {
                    var messageClientExt = iterator.next() as org.apache.rocketmq.common.message.MessageClientExt;
                    var producer1        = RocketMqHelper.CreateDefaultMQProducer("aaaaa");
                    var message          = new org.apache.rocketmq.common.message.Message("testtopic123455ssss", Encoding.UTF8.GetBytes("张三dddd"));
                    message.setDelayTimeLevel(2);

                    producer1.send(message);
                }
                catch (Exception ex)
                {
                }
            }
            return(ConsumeConcurrentlyStatus.CONSUME_SUCCESS);
        }
예제 #3
0
            public void TestMq()
            {
                ConcurrentDictionary <string, int> Dic = new ConcurrentDictionary <string, int>();

                Dic.TryAdd("ff", 1);
                Dic["ff"]++;
                Dic["ff"] = 22;

                string testTopic = "testtopic123455ssss";
                var    producer1 = RocketMqHelper.CreateDefaultMQProducer("aaaaa");

                producer1.send(new org.apache.rocketmq.common.message.Message(testTopic, Encoding.UTF8.GetBytes("张三dddd")));


                var cusomer1 = RocketMqHelper.CreateDefaultMQPushConsumer <AAMessageListenerConcurrently>("ddd");

                cusomer1.subscribe(testTopic, "*");



                Thread.Sleep(1000000);
            }
예제 #4
0
파일: UnitTest1.cs 프로젝트: can-can/wechat
            public void TestMq()
            {
                var producer1 = RocketMqHelper.CreateDefaultMQProducer("aaaaa");
                var producer2 = RocketMqHelper.CreateDefaultMQProducer("aaaaa");
                var producer3 = RocketMqHelper.CreateDefaultMQProducer("aaaaa");

                producer3.send(new org.apache.rocketmq.common.message.Message("123456", Encoding.UTF8.GetBytes("张三dddd")));

                producer3.send(new org.apache.rocketmq.common.message.Message("123456", Encoding.UTF8.GetBytes("李四3333")));
                producer3.send(new org.apache.rocketmq.common.message.Message("123456", Encoding.UTF8.GetBytes("张三dddd")));

                producer3.send(new org.apache.rocketmq.common.message.Message("123456", Encoding.UTF8.GetBytes("李四3333")));
                var cusomer1 = RocketMqHelper.CreateDefaultMQPushConsumer <AAMessageListenerConcurrently>("ddd");

                var cusomer2 = RocketMqHelper.CreateDefaultMQPushConsumer <AAMessageListenerConcurrently>("ddd");
                var cusomer3 = RocketMqHelper.CreateDefaultMQPushConsumer <AAMessageListenerConcurrently>("ddd");
                var cusomer4 = RocketMqHelper.CreateDefaultMQPushConsumer <AAMessageListenerConcurrently>("ddd");

                cusomer1.subscribe("123456", "*");

                Thread.Sleep(1000000);
            }