Java Code Examples for org.apache.rocketmq.client.producer.TransactionMQProducer#setCheckThreadPoolMinSize()
The following examples show how to use
org.apache.rocketmq.client.producer.TransactionMQProducer#setCheckThreadPoolMinSize() .
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: TransactionProducer.java From DDMQ with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); producer.setCheckThreadPoolMinSize(2); producer.setCheckThreadPoolMaxSize(2); producer.setCheckRequestHoldMax(2000); producer.setTransactionCheckListener(transactionCheckListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl(); for (int i = 0; i < 100; i++) { try { Message msg = new Message("TopicTest", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null); System.out.printf("%s%n", sendResult); Thread.sleep(10); } catch (MQClientException | UnsupportedEncodingException e) { e.printStackTrace(); } } for (int i = 0; i < 100000; i++) { Thread.sleep(1000); } producer.shutdown(); }
Example 2
Source File: TransactionProducer.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); producer.setCheckThreadPoolMinSize(2); producer.setCheckThreadPoolMaxSize(2); producer.setCheckRequestHoldMax(2000); producer.setTransactionCheckListener(transactionCheckListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl(); for (int i = 0; i < 100; i++) { try { Message msg = new Message("TopicTest", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null); System.out.printf("%s%n", sendResult); Thread.sleep(10); } catch (MQClientException | UnsupportedEncodingException e) { e.printStackTrace(); } } for (int i = 0; i < 100000; i++) { Thread.sleep(1000); } producer.shutdown(); }
Example 3
Source File: TransactionProducer.java From DDMQ with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); producer.setCheckThreadPoolMinSize(2); producer.setCheckThreadPoolMaxSize(2); producer.setCheckRequestHoldMax(2000); producer.setTransactionCheckListener(transactionCheckListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl(); for (int i = 0; i < 100; i++) { try { Message msg = new Message("TopicTest", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null); System.out.printf("%s%n", sendResult); Thread.sleep(10); } catch (MQClientException | UnsupportedEncodingException e) { e.printStackTrace(); } } for (int i = 0; i < 100000; i++) { Thread.sleep(1000); } producer.shutdown(); }
Example 4
Source File: TransactionProducer.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); producer.setCheckThreadPoolMinSize(2); producer.setCheckThreadPoolMaxSize(2); producer.setCheckRequestHoldMax(2000); producer.setTransactionCheckListener(transactionCheckListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl(); for (int i = 0; i < 100; i++) { try { Message msg = new Message("TopicTest", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null); System.out.printf("%s%n", sendResult); Thread.sleep(10); } catch (MQClientException | UnsupportedEncodingException e) { e.printStackTrace(); } } for (int i = 0; i < 100000; i++) { Thread.sleep(1000); } producer.shutdown(); }
Example 5
Source File: TransactionProducer.java From rocketmq_trans_message with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); producer.setCheckThreadPoolMinSize(2); producer.setCheckThreadPoolMaxSize(2); producer.setCheckRequestHoldMax(2000); //producer.setNamesrvAddr("127.0.0.1:9876"); producer.setNamesrvAddr("testserver004:9876"); producer.setTransactionCheckListener(transactionCheckListener); producer.start(); String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"}; TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl(); ExecutorService executorService = Executors.newFixedThreadPool(20); for (int j = 0; j < 5000; j++) { final int i = j; executorService.submit(new Runnable() { @Override public void run() { try { int xx = i; Message msg = new Message("TransactionTest", tags[i % tags.length], "KEY" + i, String.valueOf(xx).getBytes(RemotingHelper.DEFAULT_CHARSET)); long startTime = System.currentTimeMillis(); msg.putUserProperty(PropertyKeyConst.CheckImmunityTimeInSeconds, "30"); //producer.send(msg); SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, i); //System.out.println("发送消息:" + sendResult + ",消耗时间:" + (System.currentTimeMillis() - startTime) + "ms"); System.out.println("发送消息:" + xx + ",消耗时间:" + (System.currentTimeMillis() - startTime) + "ms"); statsMap.put(i, true); } catch (Exception e) { e.printStackTrace(); } } }); } for (int i = 0; i < 100000; i++) { Thread.sleep(1000); } producer.shutdown(); }