1.问题出现 搭完mq单主单从集群之后,美滋滋想发一下message, 没想到碰到一个坑爹的问题: com.alibaba.rocketmq.client.exception.MQBrokerException: CODE: 14 DESC: service not available now, maybe disk full, CL: 0.87 CQ: 0.87 INDEX: 0.87, maybe your broker machine memory too small. 1com.alibaba....
//官网示例publicstaticvoidmain(String[] args)throwsException {//实例化消息生产者ProducerDefaultMQProducer producer =newDefaultMQProducer("producerGroup_name");//设置NameServer的地址producer.setNamesrvAddr("localhost:9876");//启动Producer实例producer.start(); producer.setRetryTimesWhenSendAsyncFailed(0);...
SendResult sendResult = txnMessageEvent.getSendResult(); LocalTransactionState transactionState = LocalTransactionState.ROLLBACK_MESSAGE; endTransaction(sendResult, transactionState, new RuntimeException("事务执行失败")); log.info("Send Transaction {} {}", transactionState, sendResult.getMsgId()); }...
retryCount) { Throwable e = null; for(int i =0; i < retryCount; i ++ ) { try { return producer.send(msg,500); //设置超时时间,为500ms,内部有重试机制 } catch (Throwable e2) { e = e2; } } throw new RuntimeException("消息发送异常",e); } 1. 2. 3. 4. 5. 6. 7. 8. ...
if(sendResult!=null){System.out.println(newDate()+" Send mq message success . msgId is:"+sendResult.getMsgId());}}catch(Exception e){// 消息发送失败,需要进行重试处理,可重新发送这条消息或持久化这条数据进行补偿处理。System.out.println(newDate()+" Send mq message failed");e.print...
publicstaticSendResultsend(DefaultMQProducerproducer,Messagemsg,intretryCount){Throwablee=null;for(inti=0;i<retryCount;i++){try{returnproducer.send(msg,500);//设置超时时间,为500ms,内部有重试机制 } catch (Throwable e2) { e = e2; } } throw new RuntimeException("消息发送异常",e);} ...
private SendResult sendDefaultImpl( Message msg, final CommunicationMode communicationMode, final SendCallback sendCallback, final long timeout ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException { // 检查生产者处于运行状态 ...
sendOneway单向发送,也是异步消息发送,向Broker发送消息之后立刻返回,但是没有回调函数; publicinterfaceMQProducerextendsMQAdmin{// 同步发送消息SendResultsend(finalMessagemsg)throwsMQClientException,RemotingException,MQBrokerException,InterruptedException;// 异步发送消息,SendCallback为回调函数voidsend(finalMessagemsg,fi...
rocketMQTemplate.asyncSend("test-topic:test-tag", "test message", new SendCallback() { @Override public void onSuccess(SendResult sendResult) { // 成功回调 System.out.println("回调结果: " + sendResult); } @Override public void onException(Throwable throwable) { ...
executeSendMessageHookAfter(context); } try { sendCallback.onSuccess(sendResult); } catch (Throwable e) { } producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), false); } catch (Exception e) { producer.updateFaultItem(brokerName, System.current...