org.apache.rocketmq.client.impl.consumer.PullRequest Java Examples

The following examples show how to use org.apache.rocketmq.client.impl.consumer.PullRequest. 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: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #2
Source File: DefaultMQPushConsumerTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #3
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
private void pullMessage(final PullRequest pullRequest) {
    final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup());
    if (consumer != null) {
        long beginPullRequestTime = System.currentTimeMillis();

        DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer;
        log.debug("begin Pull Message, {}", pullRequest);
        impl.pullMessage(pullRequest);

        long rt = System.currentTimeMillis() - beginPullRequestTime;
        if (rt >= brokerHealthyManager.getIsolateThreshold()) {
            brokerHealthyManager.isolateBroker(pullRequest.getMessageQueue().getBrokerName());
        }
    } else {
        log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest);
    }
}
 
Example #4
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    log.info(this.getServiceName() + " service started");

    while (!this.isStopped()) {
        try {
            PullRequest pullRequest = this.pullRequestQueue.take();
            this.pullMessageWithHealthyManage(pullRequest);
        } catch (InterruptedException ignored) {
        } catch (Exception e) {
            log.error("Pull Message Service Run Method exception", e);
        }
    }

    log.info(this.getServiceName() + " service end");
}
 
Example #5
Source File: DeFiBusMessageListenerConcurrentlyOnceTest.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #6
Source File: DeFiBusMessageListenerConcurrentlyTest.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #7
Source File: DefaultMQPushConsumerTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #8
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #9
Source File: DefaultMQPushConsumerTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #10
Source File: DefaultMQPushConsumerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #11
Source File: DefaultMQPushConsumerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #12
Source File: DefaultMQConsumerWithTraceTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private PullRequest createPullRequest() {
    PullRequest pullRequest = new PullRequest();
    pullRequest.setConsumerGroup(consumerGroup);
    pullRequest.setNextOffset(1024);

    MessageQueue messageQueue = new MessageQueue();
    messageQueue.setBrokerName(brokerName);
    messageQueue.setQueueId(0);
    messageQueue.setTopic(topic);
    pullRequest.setMessageQueue(messageQueue);
    ProcessQueue processQueue = new ProcessQueue();
    processQueue.setLocked(true);
    processQueue.setLastLockTimestamp(System.currentTimeMillis());
    pullRequest.setProcessQueue(processQueue);

    return pullRequest;
}
 
Example #13
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
public DeFiBusPullMessageService(DeFiBusClientInstance deFiBusClientInstance) {
    super(deFiBusClientInstance);
    this.mQClientFactory = deFiBusClientInstance;
    this.brokerHealthyManager = new BrokerHealthyManager();

    pullRequestQueue = (LinkedBlockingQueue<PullRequest>) ReflectUtil.getSimpleProperty(PullMessageService.class, this, "pullRequestQueue");
}
 
Example #14
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
private void pullMessageWithHealthyManage(final PullRequest pullRequest) {
    boolean brokerAvailable = brokerHealthyManager.isBrokerAvailable(pullRequest.getMessageQueue().getBrokerName());
    if (brokerAvailable) {
        pullMessage(pullRequest);
    } else {
        runInRetryThread(pullRequest);
    }
}
 
Example #15
Source File: DeFiBusPullMessageService.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
private void runInRetryThread(PullRequest pullRequest) {
    try {
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                pullMessage(pullRequest);
            }
        });
    } catch (Exception ex) {
        log.info("execute pull message in retry thread fail.", ex);
        super.executePullRequestLater(pullRequest, 100);
    }
}