Search in sources :

Example 6 with MQProducerInner

use of org.apache.rocketmq.client.impl.producer.MQProducerInner in project rocketmq by apache.

the class ClientRemotingProcessor method checkTransactionState.

public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final CheckTransactionStateRequestHeader requestHeader = (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
    final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
    final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
    if (messageExt != null) {
        final String group = messageExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
        if (group != null) {
            MQProducerInner producer = this.mqClientFactory.selectProducer(group);
            if (producer != null) {
                final String addr = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
                producer.checkTransactionState(addr, messageExt, requestHeader);
            } else {
                log.debug("checkTransactionState, pick producer by group[{}] failed", group);
            }
        } else {
            log.warn("checkTransactionState, pick producer group failed");
        }
    } else {
        log.warn("checkTransactionState, decode message failed");
    }
    return null;
}
Also used : MessageExt(org.apache.rocketmq.common.message.MessageExt) MQProducerInner(org.apache.rocketmq.client.impl.producer.MQProducerInner) ByteBuffer(java.nio.ByteBuffer) CheckTransactionStateRequestHeader(org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader)

Aggregations

MQProducerInner (org.apache.rocketmq.client.impl.producer.MQProducerInner)6 MQConsumerInner (org.apache.rocketmq.client.impl.consumer.MQConsumerInner)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 TopicPublishInfo (org.apache.rocketmq.client.impl.producer.TopicPublishInfo)2 MessageExt (org.apache.rocketmq.common.message.MessageExt)2 CheckTransactionStateRequestHeader (org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader)2 ConsumerData (org.apache.rocketmq.common.protocol.heartbeat.ConsumerData)2 HeartbeatData (org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData)2 ProducerData (org.apache.rocketmq.common.protocol.heartbeat.ProducerData)2