com.alibaba.rocketmq.client.impl.CommunicationMode Java Examples

The following examples show how to use com.alibaba.rocketmq.client.impl.CommunicationMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #2
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #3
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * DEFAULT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #4
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void send(Message msg, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
    } catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #5
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * DEFAULT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
    } catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #6
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public SendResult send(Message msg, MessageQueue mq, long timeout)
        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, null, timeout);
}
 
Example #7
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
    } catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #8
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private SendResult sendSelectImpl(//
                                  Message msg, //
                                  MessageQueueSelector selector, //
                                  Object arg, //
                                  final CommunicationMode communicationMode, //
                                  final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
    if (topicPublishInfo != null && topicPublishInfo.ok()) {
        MessageQueue mq = null;
        try {
            mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
        } catch (Throwable e) {
            throw new MQClientException("select message queue throwed exception.", e);
        }

        if (mq != null) {
            return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, null, timeout);
        } else {
            throw new MQClientException("select message queue return null.", null);
        }
    }

    throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}
 
Example #9
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
    } catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #10
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * SELECT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
        throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
    } catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #11
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public void send(Message msg, SendCallback sendCallback, long timeout)
        throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #12
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
/**
 * KERNEL ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null, null, this.defaultMQProducer.getSendMsgTimeout());
    } catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #13
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public SendResult send(Message msg, MessageQueue mq, long timeout)
        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, timeout);
}
 
Example #14
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * KERNEL ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueue mq)
        throws MQClientException, RemotingException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #15
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
private SendResult sendSelectImpl(//
        Message msg, //
        MessageQueueSelector selector, //
        Object arg, //
        final CommunicationMode communicationMode, //
        final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
    if (topicPublishInfo != null && topicPublishInfo.ok()) {
        MessageQueue mq = null;
        try {
            mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
        }
        catch (Throwable e) {
            throw new MQClientException("select message queue throwed exception.", e);
        }

        if (mq != null) {
            return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, timeout);
        }
        else {
            throw new MQClientException("select message queue return null.", null);
        }
    }

    throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}
 
Example #16
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback,
        long timeout) throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #17
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * SELECT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
        throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #18
Source File: MessageSendInterceptorTest.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    messageSendInterceptor = new MessageSendInterceptor();
    enhancedInstance = new EnhancedInstance() {
        @Override
        public Object getSkyWalkingDynamicField() {
            return "127.0.0.1:6543";
        }

        @Override
        public void setSkyWalkingDynamicField(Object value) {

        }
    };

    arguments = new Object[] {
        "127.0.0.1",
        "test",
        message,
        messageRequestHeader,
        null,
        CommunicationMode.ASYNC,
        callBack
    };
    argumentsWithoutCallback = new Object[] {
        "127.0.0.1",
        "test",
        message,
        messageRequestHeader,
        null,
        CommunicationMode.ASYNC,
        null
    };
    when(messageRequestHeader.getProperties()).thenReturn("");
    when(message.getTags()).thenReturn("TagA");
}
 
Example #19
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
private SendResult sendSelectImpl(//
        Message msg,//
        MessageQueueSelector selector,//
        Object arg,//
        final CommunicationMode communicationMode,//
        final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
    if (topicPublishInfo != null && topicPublishInfo.ok()) {
        MessageQueue mq = null;
        try {
            mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
        }
        catch (Throwable e) {
            throw new MQClientException("select message queue throwed exception.", e);
        }

        if (mq != null) {
            return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, timeout);
        }
        else {
            throw new MQClientException("select message queue return null.", null);
        }
    }

    throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
}
 
Example #20
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * KERNEL ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException,
        InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    try {
        this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #21
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public SendResult send(Message msg, MessageQueue mq, long timeout) throws MQClientException,
        RemotingException, MQBrokerException, InterruptedException {
    this.makeSureStateOK();
    Validators.checkMessage(msg, this.defaultMQProducer);

    if (!msg.getTopic().equals(mq.getTopic())) {
        throw new MQClientException("message's topic not equal mq's topic", null);
    }

    return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, timeout);
}
 
Example #22
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback,
        long timeout) throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #23
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public void send(Message msg, SendCallback sendCallback, long timeout) throws MQClientException,
        RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknown exception", e);
    }
}
 
Example #24
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * SELECT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg, MessageQueueSelector selector, Object arg) throws MQClientException,
        RemotingException, InterruptedException {
    try {
        this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #25
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * DEFAULT ONEWAY -------------------------------------------------------
 */
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
    try {
        this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null,
            this.defaultMQProducer.getSendMsgTimeout());
    }
    catch (MQBrokerException e) {
        throw new MQClientException("unknow exception", e);
    }
}
 
Example #26
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    return this.sendSelectImpl(msg, selector, arg, CommunicationMode.SYNC, null, timeout);
}
 
Example #27
Source File: SendMessageContext.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void setCommunicationMode(CommunicationMode communicationMode) {
    this.communicationMode = communicationMode;
}
 
Example #28
Source File: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
    return this.sendSelectImpl(msg, selector, arg, CommunicationMode.SYNC, null, timeout);
}
 
Example #29
Source File: CheckForbiddenContext.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
public void setCommunicationMode(CommunicationMode communicationMode) {
    this.communicationMode = communicationMode;
}
 
Example #30
Source File: SendMessageContext.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
public void setCommunicationMode(CommunicationMode communicationMode) {
    this.communicationMode = communicationMode;
}