Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发送普通消息时rabbitTemplate.setConfirmCallback回调方法msgId为null #19

Open
ijaychang opened this issue Oct 10, 2018 · 3 comments

Comments

@ijaychang
Copy link

        // 消息发送到RabbitMQ交换器后接收ack回调
        rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
            if(returnFlag){
                logger.error("mq发送错误,无对应的的交换机,confirm回掉,ack={},correlationData={} cause={} returnFlag={}",
                        ack, correlationData, cause, returnFlag);
            }

            logger.info("confirm回调,ack={} correlationData={} cause={}", ack, correlationData, cause);
            String msgId = correlationData.getId();

            /** 只要消息能投入正确的消息队列,并持久化,就返回ack为true*/
            if(ack){
                logger.info("消息已正确投递到队列, correlationData:{}", correlationData);
                //清除重发缓存
                String dbCoordinatior = ((CompleteCorrelationData)correlationData).getCoordinator();
                DBCoordinator coordinator = (DBCoordinator)applicationContext.getBean(dbCoordinatior);
                coordinator.setMsgSuccess(msgId);
            }else{
                logger.error("消息投递至交换机失败,业务号:{},原因:{}",correlationData.getId(),cause);
            }

        });

coordinator.setMsgSuccess(msgId);报 java.lang.IllegalArgumentException: non null hash key required

@vvsuperman
Copy link
Owner

注解上的bizname设置了么?

@ijaychang
Copy link
Author

ijaychang commented Oct 11, 2018

@vvsuperman 发送不同消息也要加@TransMessage注解,设置bizname吗。不是很明白。。。

@vvsuperman
Copy link
Owner

普通消息么?不用@TransMessage?那应该去掉这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants