|  | @ -7,19 +7,22 @@ import ( | 
														
													
														
															
																|  |  | "log" |  |  | "log" | 
														
													
														
															
																|  |  | ) |  |  | ) | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | var MqPool *rocketmq.Producer |  |  |  | 
														
													
														
															
																|  |  |  |  |  | var MqPool rocketmq.Producer | 
														
													
														
															
																|  |  |  |  |  |  | 
														
													
														
															
																|  |  | func MqConnect() { |  |  |  | 
														
													
														
															
																|  |  | MqPool, err := rocketmq.NewProducer( |  |  |  | 
														
													
														
															
																|  |  | producer.WithGroupName("ProductService"), |  |  |  | 
														
													
														
															
																|  |  | producer.WithNsResolver(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})), |  |  |  | 
														
													
														
															
																|  |  |  |  |  | func MqConnect(group string, resolver []string) { | 
														
													
														
															
																|  |  |  |  |  | p, err := rocketmq.NewProducer( | 
														
													
														
															
																|  |  |  |  |  | producer.WithGroupName(group), | 
														
													
														
															
																|  |  |  |  |  | producer.WithNsResolver(primitive.NewPassthroughResolver(resolver)), | 
														
													
														
															
																|  |  | //producer.WithCreateTopicKey("product"), |  |  | //producer.WithCreateTopicKey("product"), | 
														
													
														
															
																|  |  | producer.WithRetry(1)) |  |  | producer.WithRetry(1)) | 
														
													
														
															
																|  |  | if err != nil { |  |  | if err != nil { | 
														
													
														
															
																|  |  | log.Println("New ProductService producer failed", err) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | log.Println("New "+group+" producer failed", err) | 
														
													
														
															
																|  |  |  |  |  | return | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | err = MqPool.Start() |  |  |  | 
														
													
														
															
																|  |  |  |  |  | err = p.Start() | 
														
													
														
															
																|  |  | if err != nil { |  |  | if err != nil { | 
														
													
														
															
																|  |  | log.Println("ProductService producer start failed", err) |  |  |  | 
														
													
														
															
																|  |  |  |  |  | log.Println(group+" producer start failed", err) | 
														
													
														
															
																|  |  |  |  |  | return | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  |  |  |  | MqPool = p | 
														
													
														
															
																|  |  | } |  |  | } |