±à¼ÍƼö: |
±¾ÎÄÀ´×ÔÓÚjianshu£¬ÎÄÕ½éÉÜÁËRocketmq¡¢kafka¡¢RabbitmqµÄÏêϸ¶Ô±È£¬RocketMQ¼¯Èº²¿ÊðµÈÏà¹ØÄÚÈÝ¡£ |
|
Ò»¡¢ MQ±³¾°&Ñ¡ÐÍ
ÏûÏ¢¶ÓÁÐ×÷Ϊ¸ß²¢·¢ÏµÍ³µÄºËÐÄ×é¼þÖ®Ò»£¬Äܹ»°ïÖúÒµÎñϵͳ½â¹¹ÌáÉý¿ª·¢Ð§ÂʺÍϵͳÎȶ¨ÐÔ¡£Ö÷Òª¾ßÓÐÒÔÏÂÓÅÊÆ£º
Ï÷·åÌî¹È£¨Ö÷Òª½â¾ö˲ʱдѹÁ¦´óÓÚÓ¦Ó÷þÎñÄÜÁ¦µ¼ÖÂÏûÏ¢¶ªÊ§¡¢ÏµÍ³±¼À£µÈÎÊÌ⣩
ϵͳ½âñ½â¾ö²»Í¬ÖØÒª³Ì¶È¡¢²»Í¬ÄÜÁ¦¼¶±ðϵͳ֮¼äÒÀÀµµ¼ÖÂÒ»ËÀÈ«ËÀ£©
ÌáÉýÐÔÄÜ£¨µ±´æÔÚÒ»¶Ô¶àµ÷ÓÃʱ£¬¿ÉÒÔ·¢Ò»ÌõÏûÏ¢¸øÏûϢϵͳ£¬ÈÃÏûϢϵͳ֪ͨÏà¹ØÏµÍ³£©
ÐîÁ÷ѹ²â£¨ÏßÉÏÓÐЩÁ´Â·²»ºÃѹ²â£¬¿ÉÒÔͨ¹ý¶Ñ»ýÒ»¶¨Á¿ÏûÏ¢ÔÙ·Å¿ªÀ´Ñ¹²â£©
ĿǰÖ÷Á÷µÄMQÖ÷ÒªÊÇRocketmq¡¢kafka¡¢Rabbitmq£¬RocketmqÏà±ÈÓÚRabbitmq¡¢kafka¾ßÓÐÖ÷ÒªÓÅÊÆÌØÐÔÓУº
Ö§³ÖÊÂÎñÐÍÏûÏ¢£¨ÏûÏ¢·¢ËͺÍDB²Ù×÷±£³ÖÁ½·½µÄ×îÖÕÒ»ÖÂÐÔ£¬rabbitmqºÍkafka²»Ö§³Ö£©
Ö§³Ö½áºÏrocketmqµÄ¶à¸öϵͳ֮¼äÊý¾Ý×îÖÕÒ»ÖÂÐÔ£¨¶à·½ÊÂÎñ£¬¶þ·½ÊÂÎñÊÇǰÌᣩ
Ö§³Ö18¸ö¼¶±ðµÄÑÓ³ÙÏûÏ¢£¨rabbitmqºÍkafka²»Ö§³Ö£©
Ö§³ÖÖ¸¶¨´ÎÊýºÍʱ¼ä¼ä¸ôµÄʧ°ÜÏûÏ¢ÖØ·¢£¨kafka²»Ö§³Ö£¬rabbitmqÐèÒªÊÖ¶¯È·ÈÏ£©
Ö§³Öconsumer¶Ëtag¹ýÂË£¬¼õÉÙ²»±ØÒªµÄÍøÂç´«Ê䣨rabbitmqºÍkafka²»Ö§³Ö£©
Ö§³ÖÖØ¸´Ïû·Ñ£¨rabbitmq²»Ö§³Ö£¬kafkaÖ§³Ö£©
Rocketmq¡¢kafka¡¢RabbitmqµÄÏêϸ¶Ô±È£¬Çë²ÎÕÕϱí¸ñ£º

¶þ¡¢RocketMQ¼¯Èº¸ÅÊö
1. RocketMQ¼¯Èº²¿Êð½á¹¹

1) Name Server
Name ServerÊÇÒ»¸ö¼¸ºõÎÞ״̬½Úµã£¬¿É¼¯Èº²¿Ê𣬽ڵãÖ®¼äÎÞÈκÎÐÅϢͬ²½¡£
2) Broker
Broker²¿ÊðÏà¶Ô¸´ÔÓ£¬Broker·ÖΪMasterÓëSlave£¬Ò»¸öMaster¿ÉÒÔ¶ÔÓ¦¶à¸öSlave£¬µ«ÊÇÒ»¸öSlaveÖ»ÄܶÔÓ¦Ò»¸öMaster£¬MasterÓëSlaveµÄ¶ÔÓ¦¹ØÏµÍ¨¹ýÖ¸¶¨ÏàͬµÄBroker
Name£¬²»Í¬µÄBroker IdÀ´¶¨Ò壬BrokerIdΪ0±íʾMaster£¬·Ç0±íʾSlave¡£MasterÒ²¿ÉÒÔ²¿Êð¶à¸ö¡£
ÿ¸öBrokerÓëName Server¼¯ÈºÖеÄËùÓнڵ㽨Á¢³¤Á¬½Ó£¬¶¨Ê±(ÿ¸ô30s)×¢²áTopicÐÅÏ¢µ½ËùÓÐName
Server¡£Name Server¶¨Ê±(ÿ¸ô10s)ɨÃèËùÓдæ»îbrokerµÄÁ¬½Ó£¬Èç¹ûName
Server³¬¹ý2·ÖÖÓûÓÐÊÕµ½ÐÄÌø£¬ÔòName Server¶Ï¿ªÓëBrokerµÄÁ¬½Ó¡£
3) Producer
ProducerÓëName Server¼¯ÈºÖÐµÄÆäÖÐÒ»¸ö½Úµã(Ëæ»úÑ¡Ôñ)½¨Á¢³¤Á¬½Ó£¬¶¨ÆÚ´ÓName
ServerÈ¡Topic·ÓÉÐÅÏ¢£¬²¢ÏòÌṩTopic·þÎñµÄMaster½¨Á¢³¤Á¬½Ó£¬ÇÒ¶¨Ê±ÏòMaster·¢ËÍÐÄÌø¡£ProducerÍêÈ«ÎÞ״̬£¬¿É¼¯Èº²¿Êð¡£
Producerÿ¸ô30s£¨ÓÉClientConfigµÄpollNameServerInterval£©´ÓName
server»ñÈ¡ËùÓÐtopic¶ÓÁеÄ×îÐÂÇé¿ö£¬ÕâÒâζ×ÅÈç¹ûBroker²»¿ÉÓã¬Producer×î¶à30sÄܹ»¸ÐÖª£¬ÔÚ´ËÆÚ¼äÄÚ·¢ÍùBrokerµÄËùÓÐÏûÏ¢¶¼»áʧ°Ü¡£
Producerÿ¸ô30s£¨ÓÉClientConfigÖÐheartbeatBrokerInterval¾ö¶¨£©ÏòËùÓйØÁªµÄbroker·¢ËÍÐÄÌø£¬Brokerÿ¸ô10sÖÐɨÃèËùÓдæ»îµÄÁ¬½Ó£¬Èç¹ûBrokerÔÚ2·ÖÖÓÄÚûÓÐÊÕµ½ÐÄÌøÊý¾Ý£¬Ôò¹Ø±ÕÓëProducerµÄÁ¬½Ó¡£
4) Consumer
ConsumerÓëName Server¼¯ÈºÖÐµÄÆäÖÐÒ»¸ö½Úµã(Ëæ»úÑ¡Ôñ)½¨Á¢³¤Á¬½Ó£¬¶¨ÆÚ´ÓName
ServerÈ¡Topic·ÓÉÐÅÏ¢£¬²¢ÏòÌṩTopic·þÎñµÄMaster¡¢Slave½¨Á¢³¤Á¬½Ó£¬ÇÒ¶¨Ê±ÏòMaster¡¢Slave·¢ËÍÐÄÌø¡£Consumer¼È¿ÉÒÔ´ÓMaster¶©ÔÄÏûÏ¢£¬Ò²¿ÉÒÔ´ÓSlave¶©ÔÄÏûÏ¢£¬¶©ÔĹæÔòÓÉBrokerÅäÖþö¶¨¡£
Consumerÿ¸ô30s´ÓName server»ñÈ¡topicµÄ×îжÓÁÐÇé¿ö£¬ÕâÒâζ×ÅBroker²»¿ÉÓÃʱ£¬Consumer×î¶à×îÐèÒª30s²ÅÄܸÐÖª¡£
Consumerÿ¸ô30s£¨ÓÉClientConfigÖÐheartbeatBrokerInterval¾ö¶¨£©ÏòËùÓйØÁªµÄbroker·¢ËÍÐÄÌø£¬Brokerÿ¸ô10sɨÃèËùÓдæ»îµÄÁ¬½Ó£¬Èôij¸öÁ¬½Ó2·ÖÖÓÄÚûÓз¢ËÍÐÄÌøÊý¾Ý£¬Ôò¹Ø±ÕÁ¬½Ó£»²¢Ïò¸ÃConsumer
GroupµÄËùÓÐConsumer·¢³ö֪ͨ£¬GroupÄÚµÄConsumerÖØÐ·ÖÅä¶ÓÁУ¬È»ºó¼ÌÐøÏû·Ñ¡£
µ±ConsumerµÃµ½masterå´»ú֪ͨºó£¬×ªÏòslaveÏû·Ñ£¬slave²»Äܱ£Ö¤masterµÄÏûÏ¢100%¶¼Í¬²½¹ýÀ´ÁË£¬Òò´Ë»áÓÐÉÙÁ¿µÄÏûÏ¢¶ªÊ§¡£µ«ÊÇÒ»µ©master»Ö¸´£¬Î´Í¬²½¹ýÈ¥µÄÏûÏ¢»á±»×îÖÕÏû·Ñµô¡£
Ïû·ÑÕß¶ÔÁÐÊÇÏû·ÑÕßÁ¬½ÓÖ®ºó£¨»òÕß֮ǰÓÐÁ¬½Ó¹ý£©²Å´´½¨µÄ¡£ÎÒÃǽ«ÔÉúµÄÏû·ÑÕß±êʶÓÉ
{IP}@{Ïû·ÑÕßgroup}À©Õ¹Îª {IP}@{Ïû·ÑÕßgroup}{topic}{tag}£¬£¨ÀýÈçxxx.xxx.xxx.xxx@mqtest_producer-group_2m2sTest_tag-zyk£©¡£ÈκÎÒ»¸öÔªËØ²»Í¬£¬¶¼ÈÏΪÊDz»Í¬µÄÏû·Ñ¶Ë£¬Ã¿¸öÏû·Ñ¶Ë»áÓµÓÐÒ»·Ý×Ô¼ºÏû·Ñ¶ÔÁУ¨Ä¬ÈÏÊÇbroker¶ÔÁÐÊýÁ¿*brokerÊýÁ¿£©¡£Ð¹ÒÔØµÄÏû·ÑÕß¶ÔÁÐÖÐÓµÓÐcommitlogÖеÄËùÓÐÊý¾Ý¡£
Èý¡¢ RocketmqÈçºÎÖ§³Ö·Ö²¼Ê½ÊÂÎñÏûÏ¢
³¡¾°
A£¨´æÔÚDB²Ù×÷£©¡¢B£¨´æÔÚDB²Ù×÷£©Á½·½ÐèÒª±£Ö¤·Ö²¼Ê½ÊÂÎñÒ»ÖÂÐÔ£¬Í¨¹ýÒýÈëÖмä²ãMQ£¬AºÍMQ±£³ÖÊÂÎñÒ»ÖÂÐÔ£¨Òì³£Çé¿öÏÂͨ¹ýMQ·´²éA½Ó¿ÚʵÏÖcheck£©£¬BºÍMQ±£Ö¤ÊÂÎñÒ»Ö£¨Í¨¹ýÖØÊÔ£©£¬´Ó¶ø´ïµ½×îÖÕÊÂÎñÒ»ÖÂÐÔ¡£
ÔÀí£º´óÊÂÎñ = СÊÂÎñ + Òì²½
1. MQÓëDBÒ»ÖÂÐÔÔÀí£¨Á½·½ÊÂÎñ£©
Á÷³Ìͼ

ÉÏͼÊÇRocketMQÌṩµÄ±£Ö¤MQÏûÏ¢¡¢DBÊÂÎñÒ»ÖÂÐԵķ½°¸¡£
MQÏûÏ¢¡¢DB²Ù×÷Ò»ÖÂÐÔ·½°¸£º
1)·¢ËÍÏûÏ¢µ½MQ·þÎñÆ÷£¬´ËʱÏûϢ״̬ΪSEND_OK¡£´ËÏûϢΪconsumer²»¿É¼û¡£
2)Ö´ÐÐDB²Ù×÷£»DBÖ´Ðгɹ¦Commit DB²Ù×÷£¬DBÖ´ÐÐʧ°ÜRollback DB²Ù×÷¡£
3)Èç¹ûDBÖ´Ðгɹ¦£¬»Ø¸´MQ·þÎñÆ÷£¬½«×´Ì¬ÎªCOMMIT_MESSAGE£»Èç¹ûDBÖ´ÐÐʧ°Ü£¬»Ø¸´MQ·þÎñÆ÷£¬½«×´Ì¬¸ÄΪROLLBACK_MESSAGE¡£×¢Òâ´Ë¹ý³ÌÓпÉÄÜʧ°Ü¡£
4)MQÄÚ²¿Ìṩһ¸öÃûΪ¡°ÊÂÎñ״̬·þÎñ¡±µÄ·þÎñ£¬´Ë·þÎñ»á¼ì²éÊÂÎñÏûÏ¢µÄ״̬£¬Èç¹û·¢ÏÖÏûϢδCOMMIT£¬Ôòͨ¹ýProducerÆô¶¯Ê±×¢²áµÄTransactionCheckListenerÀ´»Øµ÷ÒµÎñϵͳ£¬ÒµÎñϵͳÔÚcheckLocalTransactionState·½·¨Öмì²éDBÊÂÎñ״̬£¬Èç¹û³É¹¦£¬Ôò»Ø¸´COMMIT_MESSAGE£¬·ñÔò»Ø¸´ROLLBACK_MESSAGE¡£
˵Ã÷£º
ÉÏÃæÒÔDBΪÀý£¬Æäʵ´Ë´¦¿ÉÒÔÊÇÈκÎÒµÎñ»òÕßÊý¾ÝÔ´¡£
ÒÔÉÏSEND_OK¡¢COMMIT_MESSAGE¡¢ROLLBACK_MESSAGE¾ùÊÇclient
jarÌṩµÄ״̬£¬ÔÚMQ·þÎñÆ÷ÄÚ²¿ÊÇÒ»¸öÊý×Ö¡£
TransactionCheckListener ÊÇÔÚÏûÏ¢µÄcommit»òÕßrollbackÏûÏ¢¶ªÊ§µÄÇé¿öÏÂ²Å»á»Øµ÷£¨ÉÏͼÖлÒÉ«²¿·Ö£©¡£ÕâÖÖÏûÏ¢¶ªÊ§Ö»´æÔÚÓÚ¶ÏÍø»òÕßrocketmq¼¯Èº¹ÒÁ˵ÄÇé¿öÏ¡£µ±rocketmq¼¯Èº¹ÒÁË£¬Èç¹û²ÉÓÃÒ첽ˢÅÌ£¬´æÔÚ1sÄÚÊý¾Ý¶ªÊ§·çÏÕ£¬Ò첽ˢÅ̳¡¾°Ï±£ÕÏÊÂÎñûÓÐÒâÒå¡£ËùÒÔÈç¹ûÒªºËÐÄÒµÎñÓÃRocketmq½â¾ö·Ö²¼Ê½ÊÂÎñÎÊÌ⣬½¨ÒéÑ¡Ôñͬ²½Ë¢ÅÌģʽ¡£
2. ¶àϵͳ֮¼äÊý¾ÝÒ»ÖÂÐÔ£¨¶à·½ÊÂÎñ£©

µ±ÐèÒª±£Ö¤¶à·½£¨³¬¹ý2·½£©µÄ·Ö²¼Ê½Ò»ÖÂÐÔ£¬ÉÏÃæµÄÁ½·½ÊÂÎñÒ»ÖÂÐÔ£¨Í¨¹ýRocketmqµÄÊÂÎñÐÔÏûÏ¢½â¾ö£©ÒѾÎÞ·¨Ö§³Ö¡£Õâ¸öʱºòÐèÒªÒýÈëTCCģʽ˼Ï루Try-Confirm-Cancel£¬²»Çå³þµÄ×ÔÐаٶȣ©¡£
ÒÔÉÏͼ½»Ò×ϵͳΪÀý£º
1£©½»Ò×ϵͳ´´½¨¶©µ¥£¨ÍùDB²åÈëÒ»Ìõ¼Ç¼£©£¬Í¬Ê±·¢ËͶ©µ¥´´½¨ÏûÏ¢¡£Í¨¹ýRocketMqÊÂÎñÐÔÏûÏ¢±£Ö¤Ò»ÖÂÐÔ
2£©½Ó×ÅÖ´ÐÐÍê³É¶©µ¥ËùÐèµÄͬ²½ºËÐÄRPC·þÎñ£¨·ÇºËÐĵÄϵͳͨ¹ý¼àÌýMQÏûÏ¢×ÔÐд¦Àí£¬´¦Àí½á¹û²»»áÓ°Ïì½»Ò×״̬£©¡£Ö´Ðгɹ¦¸ü¸Ä¶©µ¥×´Ì¬£¬Í¬Ê±·¢ËÍMQÏûÏ¢¡£
3£©½»Ò×ϵͳ½ÓÊÜ×Ô¼º·¢Ë͵Ķ©µ¥´´½¨ÏûÏ¢£¬Í¨¹ý¶¨Ê±µ÷¶Èϵͳ´´½¨ÑÓʱ»Ø¹öÈÎÎñ£¨»òÕßʹÓÃRocketMqµÄÖØÊÔ¹¦ÄÜ£¬ÉèÖõڶþ´Î·¢ËÍʱ¼äΪ¶¨Ê±ÈÎÎñµÄÑÓ³Ù´´½¨Ê±¼ä¡£ÔÚ·ÇÏûÏ¢¶ÂÈûµÄÇé¿öÏ£¬ÏûÏ¢µÚÒ»´Îµ½´ïÑÓ³ÙΪ1ms×óÓÒ£¬Õâʱ¿ÉÄÜRPC»¹Î´Ö´ÐÐÍ꣬¶©µ¥×´Ì¬»¹Î´ÉèÖÃΪÍê³É£¬µÚ¶þ´ÎÏû·Ñʱ¼ä¿ÉÒÔÖ¸¶¨£©¡£ÑÓ³ÙÈÎÎñÏÈͨ¹ý²éѯ¶©µ¥×´Ì¬Åж϶©µ¥ÊÇ·ñÍê³É£¬Íê³ÉÔò²»´´½¨»Ø¹öÈÎÎñ£¬·ñÔò´´½¨¡£
PS£º¶à¸öRPC¿ÉÒÔ´´½¨Ò»¸ö»Ø¹öÈÎÎñ£¬Í¨¹ýÒ»¸öÏû·Ñ×é½ÓÊÜÒ»´ÎÏûÏ¢¾Í¿ÉÒÔ£»Ò²¿ÉÒÔͨ¹ý´´½¨¶à¸öÏû·Ñ×飬һ¸öÏûÏ¢Ïû·Ñ¶à´Î£¬Ã¿´ÎÏû·Ñ´´½¨Ò»¸öRPCµÄ»Ø¹öÈÎÎñ¡£
»Ø¹öÈÎÎñʧ°Ü£¬Í¨¹ýMQµÄÖØ·¢À´ÖØÊÔ¡£
ÒÔÉÏÊǽ»Ò×ϵͳºÍÆäËûϵͳ֮¼ä±£³Ö×îÖÕÒ»ÖÂÐԵĽâ¾ö·½°¸¡£
3.°¸Àý·ÖÎö
1) µ¥»ú»·¾³ÏµÄÊÂÎñʾÒâͼ
ÈçÏÂΪA¸øBתÕ˵ÄÀý×Ó¡£

ÒÔÉϹý³ÌÔÚ´úÂë²ãÃæÉõÖÁ¿ÉÒÔ¼ò»¯µ½ÔÚÒ»¸öÊÂÎïÖÐÖ´ÐÐÁ½ÌõsqlÓï¾ä¡£
2) ·Ö²¼Ê½»·¾³ÏÂÊÂÎñ
ºÍµ¥»úÊÂÎñ²»Í¬£¬A¡¢BÕË»§¿ÉÄܲ»ÔÚͬһ¸öDBÖУ¬´ËʱÎÞ·¨ÏñÔÚµ¥»úÇé¿öÏÂʹÓÃÊÂÎïÀ´ÊµÏÖ¡£´Ëʱ¿ÉÒÔͨ¹ýһϷ½Ê½ÊµÏÖ£¬½«×ªÕ˲Ù×÷·Ö³ÉÁ½¸ö²Ù×÷¡£
a) AÕË»§

b) MQÏûÏ¢
AÕË»§Êý¾Ý·¢Éú±ä»¯Ê±£¬·¢ËÍMQÏûÏ¢£¬MQ·þÎñÆ÷½«ÏûÏ¢ÍÆË͸ø×ªÕËϵͳ£¬×ªÕËϵͳÀ´¸øBÕ˺żÓÇ®¡£
c) BÕË»§

ËÄ¡¢ ˳ÐòÏûÏ¢
1. ˳ÐòÏûϢȱÏÝ
·¢ËÍ˳ÐòÏûÏ¢ÎÞ·¨ÀûÓü¯ÈºFail OverÌØÐÔÏû·Ñ˳ÐòÏûÏ¢µÄ²¢ÐжÈÒÀÀµÓÚ¶ÓÁÐÊýÁ¿¶ÓÁÐÈȵãÎÊÌ⣬¸ö±ð¶ÓÁÐÓÉÓÚ¹þÏ£²»¾ùµ¼ÖÂÏûÏ¢¹ý¶à£¬Ïû·ÑËٶȸú²»ÉÏ£¬²úÉúÏûÏ¢¶Ñ»ýÎÊÌâÓöµ½ÏûϢʧ°ÜµÄÏûÏ¢£¬ÎÞ·¨Ìø¹ý£¬µ±Ç°¶ÓÁÐÏû·ÑÔÝÍ£¡£
2. ÔÀí
produceÔÚ·¢ËÍÏûÏ¢µÄʱºò£¬°ÑÏûÏ¢·¢µ½Í¬Ò»¸ö¶ÓÁУ¨queue£©ÖÐ,Ïû·ÑÕß×¢²áÏûÏ¢¼àÌýÆ÷ΪMessageListenerOrderly£¬ÕâÑù¾Í¿ÉÒÔ±£Ö¤Ïû·Ñ¶ËÖ»ÓÐÒ»¸öÏß³ÌÈ¥Ïû·ÑÏûÏ¢¡£
×¢Ò⣺°ÑÏûÏ¢·¢µ½Í¬Ò»¸ö¶ÓÁУ¨queue£©£¬²»ÊÇͬһ¸ötopic£¬Ä¬ÈÏÇé¿öÏÂÒ»¸ötopic°üÀ¨4¸öqueue
3. À©Õ¹
¿ÉÒÔͨ¹ýʵÏÖ·¢ËÍÏûÏ¢µÄ¶ÔÁÐÑ¡ÔñÆ÷·½·¨£¬ÊµÏÖ²¿·Ö˳ÐòÏûÏ¢¡£
¾ÙÀý£º±ÈÈçÒ»¸öÊý¾Ý¿âͨ¹ýMQÀ´Í¬²½£¬Ö»ÐèÒª±£Ö¤Ã¿¸ö±íµÄÊý¾ÝÊÇͬ²½µÄ¾Í¿ÉÒÔ¡£½âÎöbinlog£¬½«±íÃû×÷Ϊ¶ÔÁÐÑ¡ÔñÆ÷µÄ²ÎÊý£¬ÕâÑù¾Í¿ÉÒÔ±£Ö¤Ã¿¸ö±íµÄÊý¾Ýµ½Í¬Ò»¸ö¶ÔÁÐÀïÃæ£¬´Ó¶ø±£Ö¤±íÊý¾ÝµÄ˳ÐòÏû·Ñ
Îå¡¢ ×î¼Ñʵ¼ù
1. Producer
1) Topic
Ò»¸öÓ¦Óþ¡¿ÉÄÜ .ÓÃÒ»¸öTopic£¬ÏûÏ¢×ÓÀàÐÍÓÃtagsÀ´±êʶ£¬tags¿ÉÒÔÓÉÓ¦ÓÃ×ÔÓÉÉèÖá£Ö»Óз¢ËÍÏûÏ¢ÉèÖÃÁËtags£¬Ïû·Ñ·½ÔÚ¶©ÔÄÏûϢʱ£¬²Å¿ÉÒÔÀûÓÃtags
ÔÚbroker×öÏûÏ¢¹ýÂË¡£
2) key
ÿ¸öÏûÏ¢ÔÚÒµÎñ²ãÃæµÄΨһ±êʶÂ룬ҪÉèÖõ½ keys ×ֶΣ¬·½±ã½«À´¶¨Î»ÏûÏ¢¶ªÊ§ÎÊÌâ¡£·þÎñÆ÷»áΪÿ¸öÏûÏ¢´´½¨Ë÷Òý(¹þÏ£Ë÷Òý)£¬Ó¦ÓÿÉÒÔͨ¹ý
topic£¬keyÀ´²éѯÕâÌõÏûÏ¢ÄÚÈÝ£¬ÒÔ¼°ÏûÏ¢±»ËÏû·Ñ¡£ÓÉÓÚÊǹþÏ£Ë÷Òý£¬ÇëÎñ±Ø±£Ö¤key ¾¡¿ÉÄÜΨһ£¬ÕâÑù¿ÉÒÔ±ÜÃâDZÔڵĹþÏ£³åÍ»¡£
//¶©µ¥Id
String orderId= "20034568923546";
message.setKeys(orderId);
3) ÈÕÖ¾
ÏûÏ¢·¢Ëͳɹ¦»òÕßʧ°Ü£¬Òª´òÓ¡ÏûÏ¢ÈÕÖ¾£¬Îñ±ØÒª´òÓ¡ send result ºÍkey ×ֶΡ£
4) send
sendÏûÏ¢·½·¨£¬Ö»Òª²»Å×Òì³££¬¾Í´ú±í·¢Ëͳɹ¦¡£µ«ÊÇ·¢Ëͳɹ¦»áÓжà¸ö״̬£¬ÔÚsendResultÀﶨÒå¡£
SEND_OK£ºÏûÏ¢·¢Ëͳɹ¦
FLUSH_DISK_TIMEOUT£ºÏûÏ¢·¢Ëͳɹ¦£¬µ«ÊÇ·þÎñÆ÷Ë¢Å̳¬Ê±£¬ÏûÏ¢ÒѾ½øÈë·þÎñÆ÷¶ÓÁУ¬Ö»ÓдËʱ·þÎñÆ÷å´»ú£¬ÏûÏ¢²Å»á¶ªÊ§
FLUSH_SLAVE_TIMEOUT£ºÏûÏ¢·¢Ëͳɹ¦£¬µ«ÊÇ·þÎñÆ÷ͬ²½µ½Slaveʱ³¬Ê±£¬ÏûÏ¢ÒѾ½øÈë·þÎñÆ÷¶ÓÁУ¬Ö»ÓдËʱ·þÎñÆ÷å´»ú£¬ÏûÏ¢²Å»á¶ªÊ§
SLAVE_NOT_AVAILABLE£ºÏûÏ¢·¢Ëͳɹ¦£¬µ«ÊÇ´Ëʱslave²»¿ÉÓã¬ÏûÏ¢ÒѾ½øÈë·þÎñÆ÷¶ÓÁУ¬Ö»ÓдËʱ·þÎñÆ÷å´»ú£¬ÏûÏ¢²Å»á¶ªÊ§
2. Consumer
1) ÃݵÈ
RocketMQʹÓõÄÏûÏ¢ÔÓïÊÇAt Least Once£¬ËùÒÔconsumer¿ÉÄܶà´ÎÊÕµ½Í¬Ò»¸öÏûÏ¢£¬´ËʱÎñ±Ø×öºÃÃݵȡ£
2) ÈÕÖ¾
Ïû·Ñʱ¼Ç¼ÈÕÖ¾£¬ÒÔ±ãºóÐø¶¨Î»ÎÊÌâ¡£
3) ÅúÁ¿Ïû·Ñ
¾¡Á¿Ê¹ÓÃÅúÁ¿·½Ê½Ïû·Ñ·½Ê½£¬¿ÉÒԺܴó³Ì¶ÈÉÏÌá¸ßÏû·ÑÍÌÍÂÁ¿¡£ |