You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/03/29 02:39:10 UTC

[GitHub] [rocketmq-client-go] duffiye opened a new issue #465: [Native] Should shutdown producer when sended a message

duffiye opened a new issue #465: [Native] Should shutdown producer when sended a message
URL: https://github.com/apache/rocketmq-client-go/issues/465
 
 
   send a message like this:
   
   ```
   func SendWithdrawalQueryMsg(message string, delayTimeLevel int) error {
   	p, _ := rocketmq.NewProducer(
   		producer.WithGroupName("ZB_WALLET_QUERY_GROUP"),
   		producer.WithNameServer(config.Config.Rocket.Servers),
   		producer.WithRetry(2),
   	)
   	err := p.Start()
   	if err != nil {
   		fmt.Printf("start producer error: %s", err.Error())
   		// os.Exit(1)
   	}
   	msg := primitive.NewMessage("ZB_QUERY_TOPIC", []byte(message))
   	if delayTimeLevel > 0 {
   		msg.WithDelayTimeLevel(delayTimeLevel)
   	}
   	res, err := p.SendSync(context.Background(), msg)
   
   	if err != nil {
   		fmt.Printf("send message error: %s\n", err)
   		util.DingTalkTextMsg(fmt.Sprintf("发送提现查询队列[ZB_QUERY_TOPIC]异常,ID[%s]", message), config.Config.Alert.Mobiles)
   		return err
   	}
   	fmt.Printf("发送提现查询队列 success: result=%s\n", res.String())
   	err = p.Shutdown()
   	if err != nil {
   		fmt.Printf("send message error: %s\n", err)
   		return err
   	}
   	return nil
   
   }`
   ```
   if  send message again, then get error
   `send message error: service close is not running, please check`
   if  there have no `	err = p.Shutdown()` works well, send message successful .
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq-client-go] ShannonDing commented on issue #465: [Native] Should shutdown producer when sended a message

Posted by GitBox <gi...@apache.org>.
ShannonDing commented on issue #465: [Native] Should shutdown producer when sended a message
URL: https://github.com/apache/rocketmq-client-go/issues/465#issuecomment-605838599
 
 
   create the producer instance once and keep it running until it is never used.
   here are some examples:
   https://github.com/apache/rocketmq-client-go/blob/native/examples/producer/simple/main.go

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [rocketmq-client-go] ShannonDing closed issue #465: [Native] Should shutdown producer when sended a message

Posted by GitBox <gi...@apache.org>.
ShannonDing closed issue #465: [Native] Should shutdown producer when sended a message
URL: https://github.com/apache/rocketmq-client-go/issues/465
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services