當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultMQPushConsumerImpl類代碼示例

本文整理匯總了Java中org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl的典型用法代碼示例。如果您正苦於以下問題:Java DefaultMQPushConsumerImpl類的具體用法?Java DefaultMQPushConsumerImpl怎麽用?Java DefaultMQPushConsumerImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultMQPushConsumerImpl類屬於org.apache.rocketmq.client.impl.consumer包,在下文中一共展示了DefaultMQPushConsumerImpl類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: adjustThreadPool

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
public void adjustThreadPool() {
    Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, MQConsumerInner> entry = it.next();
        MQConsumerInner impl = entry.getValue();
        if (impl != null) {
            try {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl;
                    dmq.adjustThreadPool();
                }
            } catch (Exception e) {
            }
        }
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:17,代碼來源:MQClientInstance.java

示例2: consumeMessageDirectly

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, //
    final String consumerGroup, //
    final String brokerName) {
    MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
    if (null != mqConsumerInner) {
        DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;

        ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
        return result;
    }

    return null;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:14,代碼來源:MQClientInstance.java

示例3: consumeMessageDirectly

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg,
    final String consumerGroup,
    final String brokerName) {
    MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
    if (null != mqConsumerInner) {
        DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;

        ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
        return result;
    }

    return null;
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:14,代碼來源:MQClientInstance.java

示例4: getDefaultMQPushConsumerImpl

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
public DefaultMQPushConsumerImpl getDefaultMQPushConsumerImpl() {
    return defaultMQPushConsumerImpl;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:4,代碼來源:DefaultMQPushConsumer.java

示例5: init

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
@Before
public void init() throws Exception {
    consumerGroup = "FooBarGroup" + System.currentTimeMillis();
    pushConsumer = new DefaultMQPushConsumer(consumerGroup);
    pushConsumer.setNamesrvAddr("127.0.0.1:9876");
    pushConsumer.setPullInterval(60 * 1000);

    pushConsumer.registerMessageListener(new MessageListenerConcurrently() {
        @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            return null;
        }
    });

    DefaultMQPushConsumerImpl pushConsumerImpl = pushConsumer.getDefaultMQPushConsumerImpl();
    rebalancePushImpl = spy(new RebalancePushImpl(pushConsumer.getDefaultMQPushConsumerImpl()));
    Field field = DefaultMQPushConsumerImpl.class.getDeclaredField("rebalanceImpl");
    field.setAccessible(true);
    field.set(pushConsumerImpl, rebalancePushImpl);
    pushConsumer.subscribe(topic, "*");
    pushConsumer.start();

    mQClientFactory = spy(pushConsumerImpl.getmQClientFactory());
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("mQClientFactory");
    field.setAccessible(true);
    field.set(pushConsumerImpl, mQClientFactory);


    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mQClientFactory, mQClientAPIImpl);

    pullAPIWrapper = spy(new PullAPIWrapper(mQClientFactory, consumerGroup, false));
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("pullAPIWrapper");
    field.setAccessible(true);
    field.set(pushConsumerImpl, pullAPIWrapper);

    pushConsumer.getDefaultMQPushConsumerImpl().getRebalanceImpl().setmQClientFactory(mQClientFactory);
    mQClientFactory.registerConsumer(consumerGroup, pushConsumerImpl);

    when(mQClientFactory.getMQClientAPIImpl().pullMessage(anyString(), any(PullMessageRequestHeader.class),
        anyLong(), any(CommunicationMode.class), nullable(PullCallback.class)))
        .thenAnswer(new Answer<Object>() {
        @Override public Object answer(InvocationOnMock mock) throws Throwable {
            PullMessageRequestHeader requestHeader = mock.getArgument(1);
            MessageClientExt messageClientExt = new MessageClientExt();
            messageClientExt.setTopic(topic);
            messageClientExt.setQueueId(0);
            messageClientExt.setMsgId("123");
            messageClientExt.setBody(new byte[] {'a'});
            messageClientExt.setOffsetMsgId("234");
            messageClientExt.setBornHost(new InetSocketAddress(8080));
            messageClientExt.setStoreHost(new InetSocketAddress(8080));
            PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.<MessageExt>singletonList(messageClientExt));
            ((PullCallback)mock.getArgument(4)).onSuccess(pullResult);
            return pullResult;
        }
    });

    doReturn(new FindBrokerResult("127.0.0.1:10911", false)).when(mQClientFactory).findBrokerAddressInSubscribe(anyString(), anyLong(), anyBoolean());
    doReturn(Collections.singletonList(mQClientFactory.getClientId())).when(mQClientFactory).findConsumerIdList(anyString(), anyString());
    Set<MessageQueue> messageQueueSet = new HashSet<MessageQueue>();
    messageQueueSet.add(createPullRequest().getMessageQueue());
    pushConsumer.getDefaultMQPushConsumerImpl().updateTopicSubscribeInfo(topic, messageQueueSet);
    doReturn(123L).when(rebalancePushImpl).computePullFromWhere(any(MessageQueue.class));
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:67,代碼來源:DefaultMQPushConsumerTest.java

示例6: init

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
@Before
public void init() throws Exception {
    consumerGroup = "FooBarGroup" + System.currentTimeMillis();
    pushConsumer = new DefaultMQPushConsumer(consumerGroup);
    pushConsumer.setNamesrvAddr("127.0.0.1:9876");
    pushConsumer.setPullInterval(60 * 1000);

    pushConsumer.registerMessageListener(new MessageListenerConcurrently() {
        @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            return null;
        }
    });

    DefaultMQPushConsumerImpl pushConsumerImpl = pushConsumer.getDefaultMQPushConsumerImpl();
    rebalancePushImpl = spy(new RebalancePushImpl(pushConsumer.getDefaultMQPushConsumerImpl()));
    Field field = DefaultMQPushConsumerImpl.class.getDeclaredField("rebalanceImpl");
    field.setAccessible(true);
    field.set(pushConsumerImpl, rebalancePushImpl);
    pushConsumer.subscribe(topic, "*");
    pushConsumer.start();

    mQClientFactory = spy(pushConsumerImpl.getmQClientFactory());
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("mQClientFactory");
    field.setAccessible(true);
    field.set(pushConsumerImpl, mQClientFactory);


    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mQClientFactory, mQClientAPIImpl);

    pullAPIWrapper = spy(new PullAPIWrapper(mQClientFactory, consumerGroup, false));
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("pullAPIWrapper");
    field.setAccessible(true);
    field.set(pushConsumerImpl, pullAPIWrapper);

    pushConsumer.getDefaultMQPushConsumerImpl().getRebalanceImpl().setmQClientFactory(mQClientFactory);
    mQClientFactory.registerConsumer(consumerGroup, pushConsumerImpl);

    when(mQClientFactory.getMQClientAPIImpl().pullMessage(anyString(), any(PullMessageRequestHeader.class),
        anyLong(), any(CommunicationMode.class), nullable(PullCallback.class)))
        .thenAnswer(new Answer<Object>() {
        @Override public Object answer(InvocationOnMock mock) throws Throwable {
            PullMessageRequestHeader requestHeader = mock.getArgument(1);
            MessageClientExt messageClientExt = new MessageClientExt();
            messageClientExt.setTopic(topic);
            messageClientExt.setQueueId(0);
            messageClientExt.setMsgId("123");
            messageClientExt.setBody(new byte[] {'a'});
            messageClientExt.setOffsetMsgId("234");
            messageClientExt.setBornHost(new InetSocketAddress(8080));
            messageClientExt.setStoreHost(new InetSocketAddress(8080));
            PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.<MessageExt>singletonList(messageClientExt));
            ((PullCallback)mock.getArgument(4)).onSuccess(pullResult);
            return pullResult;
        }
    });

    doReturn(new FindBrokerResult("127.0.0.1:10911", false)).when(mQClientFactory).findBrokerAddressInSubscribe(anyString(), anyLong(), anyBoolean());
    doReturn(Collections.singletonList(mQClientFactory.getClientId())).when(mQClientFactory).findConsumerIdList(anyString(), anyString());
    Set<MessageQueue> messageQueueSet = new HashSet<>();
    messageQueueSet.add(createPullRequest().getMessageQueue());
    pushConsumer.getDefaultMQPushConsumerImpl().updateTopicSubscribeInfo(topic, messageQueueSet);
    doReturn(123L).when(rebalancePushImpl).computePullFromWhere(any(MessageQueue.class));
}
 
開發者ID:lyy4j,項目名稱:rmq4note,代碼行數:67,代碼來源:DefaultMQPushConsumerTest.java

示例7: init

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
@Before
public void init() throws Exception {
    consumerGroup = "FooBarGroup" + System.currentTimeMillis();
    pushConsumer = new DefaultMQPushConsumer(consumerGroup);
    pushConsumer.setNamesrvAddr("127.0.0.1:9876");
    pushConsumer.setPullInterval(60 * 1000);

    pushConsumer.registerMessageListener(new MessageListenerConcurrently() {
        @Override
        public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
            ConsumeConcurrentlyContext context) {
            return null;
        }
    });

    DefaultMQPushConsumerImpl pushConsumerImpl = pushConsumer.getDefaultMQPushConsumerImpl();
    rebalancePushImpl = spy(new RebalancePushImpl(pushConsumer.getDefaultMQPushConsumerImpl()));
    Field field = DefaultMQPushConsumerImpl.class.getDeclaredField("rebalanceImpl");
    field.setAccessible(true);
    field.set(pushConsumerImpl, rebalancePushImpl);
    pushConsumer.subscribe(topic, "*");
    pushConsumer.start();

    mQClientFactory = spy(pushConsumerImpl.getmQClientFactory());
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("mQClientFactory");
    field.setAccessible(true);
    field.set(pushConsumerImpl, mQClientFactory);

    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mQClientFactory, mQClientAPIImpl);

    pullAPIWrapper = spy(new PullAPIWrapper(mQClientFactory, consumerGroup, false));
    field = DefaultMQPushConsumerImpl.class.getDeclaredField("pullAPIWrapper");
    field.setAccessible(true);
    field.set(pushConsumerImpl, pullAPIWrapper);

    pushConsumer.getDefaultMQPushConsumerImpl().getRebalanceImpl().setmQClientFactory(mQClientFactory);
    mQClientFactory.registerConsumer(consumerGroup, pushConsumerImpl);

    when(mQClientFactory.getMQClientAPIImpl().pullMessage(anyString(), any(PullMessageRequestHeader.class),
        anyLong(), any(CommunicationMode.class), nullable(PullCallback.class)))
        .thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock mock) throws Throwable {
                PullMessageRequestHeader requestHeader = mock.getArgument(1);
                MessageClientExt messageClientExt = new MessageClientExt();
                messageClientExt.setTopic(topic);
                messageClientExt.setQueueId(0);
                messageClientExt.setMsgId("123");
                messageClientExt.setBody(new byte[] {'a'});
                messageClientExt.setOffsetMsgId("234");
                messageClientExt.setBornHost(new InetSocketAddress(8080));
                messageClientExt.setStoreHost(new InetSocketAddress(8080));
                PullResult pullResult = createPullResult(requestHeader, PullStatus.FOUND, Collections.<MessageExt>singletonList(messageClientExt));
                ((PullCallback) mock.getArgument(4)).onSuccess(pullResult);
                return pullResult;
            }
        });

    doReturn(new FindBrokerResult("127.0.0.1:10911", false)).when(mQClientFactory).findBrokerAddressInSubscribe(anyString(), anyLong(), anyBoolean());
    doReturn(Collections.singletonList(mQClientFactory.getClientId())).when(mQClientFactory).findConsumerIdList(anyString(), anyString());
    Set<MessageQueue> messageQueueSet = new HashSet<MessageQueue>();
    messageQueueSet.add(createPullRequest().getMessageQueue());
    pushConsumer.getDefaultMQPushConsumerImpl().updateTopicSubscribeInfo(topic, messageQueueSet);
    doReturn(123L).when(rebalancePushImpl).computePullFromWhere(any(MessageQueue.class));
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:68,代碼來源:DefaultMQPushConsumerTest.java

示例8: DefaultMQPushConsumer

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
/**
 * Constructor specifying consumer group, RPC hook and message queue allocating algorithm.
 *
 * @param consumerGroup Consume queue.
 * @param rpcHook RPC hook to execute before each remoting command.
 * @param allocateMessageQueueStrategy message queue allocating algorithm.
 */
public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook,
    AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
    this.consumerGroup = consumerGroup;
    this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
    defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:14,代碼來源:DefaultMQPushConsumer.java

示例9: DefaultMQPushConsumer

import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; //導入依賴的package包/類
/**
 * Constructor specifying consumer group, RPC hook and message queue allocating algorithm.
 * @param consumerGroup Consume queue.
 * @param rpcHook RPC hook to execute before each remoting command.
 * @param allocateMessageQueueStrategy message queue allocating algorithm.
 */
public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook, AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
    this.consumerGroup = consumerGroup;
    this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
    defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:12,代碼來源:DefaultMQPushConsumer.java


注:本文中的org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。