org.apache.rocketmq.client.producer.TransactionListener Java Examples
The following examples show how to use
org.apache.rocketmq.client.producer.TransactionListener.
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 rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionListener transactionListener = new TransactionListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName("client-transaction-msg-check-thread"); return thread; } }); producer.setExecutorService(executorService); producer.setTransactionListener(transactionListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; for (int i = 0; i < 10; i++) { try { Message msg = new Message("TopicTest1234", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, 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: DefaultMQProducerImpl.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Override public TransactionListener checkListener() { if (this.defaultMQProducer instanceof TransactionMQProducer) { TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer; return producer.getTransactionListener(); } return null; }
Example #3
Source File: TransactionProducer.java From rocketmq-read with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionListener transactionListener = new TransactionListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName("client-transaction-msg-check-thread"); return thread; } }); producer.setExecutorService(executorService); producer.setTransactionListener(transactionListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; for (int i = 0; i < 10; i++) { try { Message msg = new Message("TopicTest1234", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, 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: DefaultMQProducerImpl.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 获取事务回查checklistener * @return ; */ @Override public TransactionListener getCheckListener() { if (this.defaultMQProducer instanceof TransactionMQProducer) { TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer; return producer.getTransactionListener(); } return null; }
Example #5
Source File: TransactionProducerTest.java From blog with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionListener transactionListener = new TransactionListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("transactionProducerGroupName"); producer.setNamesrvAddr("192.168.237.128:9876"); ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName("client-transaction-msg-check-thread"); return thread; } }); producer.setExecutorService(executorService); producer.setTransactionListener(transactionListener); producer.start(); String[] tags = new String[] { "TagA", "TagB", "TagC", "TagD", "TagE" }; for (int i = 0; i < 1; i++) { try { Message msg = new Message("TopicTest1234", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); System.out.println("start send message " + msg); SendResult sendResult = producer.sendMessageInTransaction(msg, 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 #6
Source File: TransactionProducer.java From rocketmq with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionListener transactionListener = new TransactionListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name"); ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName("client-transaction-msg-check-thread"); return thread; } }); producer.setExecutorService(executorService); producer.setTransactionListener(transactionListener); producer.start(); String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; for (int i = 0; i < 10; i++) { try { Message msg = new Message("TopicTest1234", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(msg, 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 #7
Source File: DefaultMQProducerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public TransactionListener getCheckListener() { if (this.defaultMQProducer instanceof TransactionMQProducer) { TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer; return producer.getTransactionListener(); } return null; }
Example #8
Source File: RMQTransactionalProducer.java From rocketmq with Apache License 2.0 | 5 votes |
protected void create(boolean useTLS, TransactionListener transactionListener) { producer = new TransactionMQProducer(); producer.setProducerGroup(getProducerGroupName()); producer.setInstanceName(getProducerInstanceName()); producer.setTransactionListener(transactionListener); producer.setUseTLS(useTLS); if (nsAddr != null) { producer.setNamesrvAddr(nsAddr); } }
Example #9
Source File: BaseConf.java From rocketmq with Apache License 2.0 | 5 votes |
public static RMQTransactionalProducer getTransactionalProducer(String nsAddr, String topic, TransactionListener transactionListener) { RMQTransactionalProducer producer = new RMQTransactionalProducer(nsAddr, topic, false, transactionListener); if (debug) { producer.setDebug(); } mqClients.add(producer); return producer; }
Example #10
Source File: TransactionProducer.java From java-tutorial with MIT License | 4 votes |
public static void main(String[] args) throws MQClientException, InterruptedException { TransactionListener transactionListener = new TransactionListenerImpl(); TransactionMQProducer producer = new TransactionMQProducer("transaction_Producer"); producer.setNamesrvAddr(NAMESRVADDR); ExecutorService executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2000), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName("client-transaction-msg-check-thread"); return thread; } }); producer.setExecutorService(executorService); producer.setTransactionListener(transactionListener); producer.start(); String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"}; for (int i = 0; i < 10; i++) { try { Message message = new Message("TopicTransactionTest", tags[i % tags.length], "KEY" + i, ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.sendMessageInTransaction(message, 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 #11
Source File: DefaultRocketMQConfiguration.java From j360-boot-app-all with Apache License 2.0 | 4 votes |
@Override protected TransactionListener newTxListener() { return new RocketMQTransactionListener(); }
Example #12
Source File: RMQTransactionalProducer.java From rocketmq with Apache License 2.0 | 4 votes |
public RMQTransactionalProducer(String nsAddr, String topic, TransactionListener transactionListener) { this(nsAddr, topic, false, transactionListener); }
Example #13
Source File: RMQTransactionalProducer.java From rocketmq with Apache License 2.0 | 4 votes |
public RMQTransactionalProducer(String nsAddr, String topic, boolean useTLS, TransactionListener transactionListener) { super(topic); this.nsAddr = nsAddr; create(useTLS, transactionListener); start(); }
Example #14
Source File: MQProducerInner.java From rocketmq-read with Apache License 2.0 | 2 votes |
/** * 获取 transactionListener * @return ; */ TransactionListener getCheckListener();
Example #15
Source File: MQProducerInner.java From rocketmq-4.3.0 with Apache License 2.0 | votes |
TransactionListener checkListener();
Example #16
Source File: MQProducerInner.java From rocketmq with Apache License 2.0 | votes |
TransactionListener getCheckListener();