Java Code Examples for org.apache.rocketmq.client.producer.DefaultMQProducer#setProducerGroup()

The following examples show how to use org.apache.rocketmq.client.producer.DefaultMQProducer#setProducerGroup() . 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: ProducerTest.java    From message-queue-client-framework with Apache License 2.0 6 votes vote down vote up
@Test
    public void test() throws Exception {

        DefaultMQProducer defaultMQProducer = new DefaultMQProducer();
        defaultMQProducer.setNamesrvAddr("localhost:9876");
        defaultMQProducer.setProducerGroup("protest");
        defaultMQProducer.start();

        MessageProducer messageProducer = new MessageProducer();
        messageProducer.setDefaultMQProducer(defaultMQProducer);
        messageProducer.setMessageEncoder(new RocketmqMessageEncoderDemo());
        messageProducer.setTopic("QUEUE_TEST");

//        for (int i = 0; i < 100; i++)
//
//            messageProducer.sendWithKey(String.valueOf(i), "test"+i);

        defaultMQProducer.shutdown();
    }
 
Example 2
Source File: RocketMQConfig.java    From flink-learning with Apache License 2.0 6 votes vote down vote up
/**
 * 构建 producer 配置
 *
 * @param props    Properties
 * @param producer DefaultMQProducer
 */
public static void buildProducerConfigs(Properties props, DefaultMQProducer producer) {
    buildCommonConfigs(props, producer);

    String group = props.getProperty(PRODUCER_GROUP);
    if (StringUtils.isEmpty(group)) {
        group = UUID.randomUUID().toString();
    }
    producer.setProducerGroup(props.getProperty(PRODUCER_GROUP, group));

    producer.setRetryTimesWhenSendFailed(getInteger(props,
            PRODUCER_RETRY_TIMES, DEFAULT_PRODUCER_RETRY_TIMES));
    producer.setRetryTimesWhenSendAsyncFailed(getInteger(props,
            PRODUCER_RETRY_TIMES, DEFAULT_PRODUCER_RETRY_TIMES));
    producer.setSendMsgTimeout(getInteger(props,
            PRODUCER_TIMEOUT, DEFAULT_PRODUCER_TIMEOUT));
}
 
Example 3
Source File: RMQNormalProducer.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
protected void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 4
Source File: RMQAsyncSendProducer.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 5
Source File: RMQAsyncSendProducer.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 6
Source File: RMQAsyncSendProducer.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 7
Source File: RMQNormalProducer.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
protected void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 8
Source File: RMQAsyncSendProducer.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 9
Source File: RMQNormalProducer.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
protected void create(boolean useTLS) {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());
    producer.setUseTLS(useTLS);

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }
}
 
Example 10
Source File: RMQAsyncSendProducer.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 11
Source File: RMQNormalProducer.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
protected void create(boolean useTLS) {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());
    producer.setUseTLS(useTLS);

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }
}
 
Example 12
Source File: RMQAsyncSendProducer.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 13
Source File: RMQNormalProducer.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
protected void create(boolean useTLS) {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());
    producer.setUseTLS(useTLS);

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }
}
 
Example 14
Source File: RMQAsyncSendProducer.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 15
Source File: RMQNormalProducer.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
protected void create(boolean useTLS) {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());
    producer.setUseTLS(useTLS);

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }
}
 
Example 16
Source File: RMQAsyncSendProducer.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void create() {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(RandomUtil.getStringByUUID());
    producer.setInstanceName(RandomUtil.getStringByUUID());

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }

}
 
Example 17
Source File: RMQNormalProducer.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
protected void create(boolean useTLS) {
    producer = new DefaultMQProducer();
    producer.setProducerGroup(getProducerGroupName());
    producer.setInstanceName(getProducerInstanceName());
    producer.setUseTLS(useTLS);

    if (nsAddr != null) {
        producer.setNamesrvAddr(nsAddr);
    }
}
 
Example 18
Source File: RocketMQConfig.java    From enode with MIT License 5 votes vote down vote up
@Bean(initMethod = "start", destroyMethod = "shutdown")
public DefaultMQProducer commandProducer() {
    DefaultMQProducer producer = new DefaultMQProducer();
    producer.setNamesrvAddr(QueueProperties.NAMESRVADDR);
    producer.setProducerGroup(QueueProperties.DEFAULT_PRODUCER_GROUP);
    return producer;
}
 
Example 19
Source File: RocketMQEventConfig.java    From enode with MIT License 5 votes vote down vote up
@Bean(initMethod = "start", destroyMethod = "shutdown")
public DefaultMQProducer defaultMQProducer() {
    DefaultMQProducer producer = new DefaultMQProducer();
    producer.setNamesrvAddr(QueueProperties.NAMESRVADDR);
    producer.setProducerGroup(QueueProperties.DEFAULT_PRODUCER_GROUP);
    return producer;
}
 
Example 20
Source File: RocketMQCommandConfig.java    From enode with MIT License 5 votes vote down vote up
@Bean(initMethod = "start", destroyMethod = "shutdown")
public DefaultMQProducer defaultMQProducer() {
    DefaultMQProducer producer = new DefaultMQProducer();
    producer.setNamesrvAddr(QueueProperties.NAMESRVADDR);
    producer.setProducerGroup(QueueProperties.DEFAULT_PRODUCER_GROUP);
    return producer;
}