/// <summary> /// /// </summary> /// <param name="args"></param> private static void Main(string[] args) { #region 生产消息 DefaultMQProducer producer = null; try { ////wulangtes 是分组名字,用来区分生产者 producer = new DefaultMQProducer("wulangtes"); ////服务器ip producer.setNamesrvAddr("192.168.10.2:9876"); producer.start(); ////Go_Ticket_WuLang_Test 为 toptic 名字,taga是比toptic更为精确地内容划分,RocketMQ会重试是内容 Message msg = new Message("Go_Ticket_WuLang_Test", "TagA", Encoding.UTF8.GetBytes("RocketMQ会重试 ")); SendResult sendResult = producer.send(msg); } finally { producer.shutdown(); } #endregion #region 消费者 DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("test"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.setNamesrvAddr("192.168.10.2:9876"); ////Go_Ticket_WuLang_Test toptic名字,* 表示不过滤tag,如果过滤,可使用 ||划分 consumer.subscribe("Go_Ticket_WuLang_Test", "*"); consumer.registerMessageListener(new TestListener()); consumer.start(); #endregion }
static void Main(string[] args) { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ExampleConsumer"); consumer.subscribe("TestTopic", "*"); consumer.registerMessageListener(new TestListner()); consumer.start(); }
static void Main(string[] args) { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroup"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.subscribe("defaulttopic", "*"); consumer.registerMessageListener(new TestListener()); consumer.start(); Console.WriteLine("Consumer Started."); }
static void Main(string[] args) { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("test"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.setNamesrvAddr("192.168.100.3:9876"); consumer.subscribe("defaulttopic", "*"); consumer.registerMessageListener(new TestListener()); consumer.start(); }
public void ConsumerMethod() { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroup"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.subscribe("TopicTest", "*"); consumer.registerMessageListener(new MessageListener()); consumer.start(); }
public void Consumer() { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroup"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.subscribe("TopicTest", "*"); //TagA || TagC || TagD consumer.registerMessageListener(new OrderedListener()); consumer.start(); Console.WriteLine("Consumer started ......"); }
public void Consumer() { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("BroadcastConsumer"); consumer.setMessageModel(MessageModel.BROADCASTING); consumer.subscribe("TopicBroadcast", "*"); consumer.registerMessageListener(new MessageListener()); consumer.start(); Console.WriteLine("Consumer started ....."); }
static void Main(string[] args) { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("example_group_name"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.subscribe("TopicTest", "TagA || TagC || TagD"); consumer.registerMessageListener(new TestListener1()); consumer.start(); Console.WriteLine("Consumer Started"); }
static void Main(string[] args) { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("BroadcastConsumerGroup"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.setMessageModel(MessageModel.BROADCASTING); consumer.subscribe("BroadTopicTest", "TagA"); consumer.registerMessageListener(new TestListener()); consumer.start(); Console.WriteLine("Broadcast Consumer Started."); }
public void Start() { #region 初始化同步用户信息 //RedisCache cache = RedisCache.CreateInstance(); //var customerInfoCaches = cache.HashGetAll<CustomerInfoCache>(ConstCacheKey.GetWxIdKey()); //var producer = RocketMqHelper.CreateDefaultMQProducer(MqConst.UserSyncMessageProducerGroup); //foreach (var item in customerInfoCaches) //{ // Util.Log.Logger.GetLog<SyncMessageListener>().Info($"初始化微信Id:{item.WxId}"); // producer.SendMessage(new org.apache.rocketmq.common.message.Message(MqConst.UserSyncMessageTopic, Encoding.UTF8.GetBytes(item.WxId))); //} #endregion consumer.subscribe(MqConst.UserSyncMessageTopic, "*"); Util.Log.Logger.GetLog <SyncMessageListener>().Info("启动同步微信消息服务成功"); }
static void Main(string[] args) { try { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("test"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.setNamesrvAddr("192.168.1.15:9876"); consumer.subscribe("defaulttopic", "*"); consumer.registerMessageListener(new TestListener()); consumer.start(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
static void Main(string[] args) { try { string topic = "topicF"; DefaultMQPushConsumer _consumer = new DefaultMQPushConsumer("prod900900"); _consumer.setNamesrvAddr("localhost:9876"); // _consumer.setVipChannelEnabled(false); _consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); _consumer.subscribe(topic, "*"); RoutingListener listener = new RoutingListener(); _consumer.registerMessageListener(listener); _consumer.start(); //_consumer.createTopic("TBW102", topic, 4); // Console.ReadKey(); } catch (Exception ex) { } }
public void Start() { consumer.subscribe(MqConst.UploadOssTopic, "*"); Util.Log.Logger.GetLog <UploadOssMessageListener>().Info("上传oss文件服务启动成功"); }