This is an automated email from the ASF dual-hosted git repository. duhengforever pushed a commit to branch OpenMessaging in repository https://gitbox.apache.org/repos/asf/rocketmq-ons.git
commit 9cb0ab2ef356a773d4ec238c2df8104a7bb29af5 Author: duhenglucky <[email protected]> AuthorDate: Fri Jul 12 10:02:48 2019 +0800 Remove System.out.println in sample and changed to standarded apache license --- .../org/apache/rocketmq/ons/sample/MQConfig.java | 19 +++++++-------- .../ons/sample/consumer/MessageListenerImpl.java | 22 +++++++++--------- .../ons/sample/consumer/SimpleMQConsumer.java | 22 +++++++++--------- .../ons/sample/consumer/SimpleOrderConsumer.java | 25 ++++++++++---------- .../producer/LocalTransactionCheckerImpl.java | 22 +++++++++--------- .../ons/sample/producer/MQTimerProducer.java | 26 ++++++++++----------- .../ons/sample/producer/SimpleMQProducer.java | 27 +++++++++++----------- .../ons/sample/producer/SimpleOrderProducer.java | 26 ++++++++++----------- .../sample/producer/SimpleTransactionProducer.java | 25 ++++++++++---------- 9 files changed, 108 insertions(+), 106 deletions(-) diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/MQConfig.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/MQConfig.java index a7d8094..2ef0e44 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/MQConfig.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/MQConfig.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/MessageListenerImpl.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/MessageListenerImpl.java index f8e8ec1..1205ce9 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/MessageListenerImpl.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/MessageListenerImpl.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +16,6 @@ */ package org.apache.rocketmq.ons.sample.consumer; -import java.util.Date; import org.apache.rocketmq.ons.api.Action; import org.apache.rocketmq.ons.api.ConsumeContext; import org.apache.rocketmq.ons.api.Message; @@ -24,7 +24,7 @@ import org.apache.rocketmq.ons.api.MessageListener; public class MessageListenerImpl implements MessageListener { @Override public Action consume(Message message, ConsumeContext consumeContext) { - System.out.println(new Date() + " Receive message, Topic is:" + message.getTopic() + ", MsgId is:" + message.getMsgID()); + System.out.printf("Receive message, Topic is: %s, MsgId is: %s%n", message.getTopic(), message.getMsgID()); return Action.CommitMessage; } } diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleMQConsumer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleMQConsumer.java index 4c4f58b..df95829 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleMQConsumer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleMQConsumer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,9 +34,8 @@ public class SimpleMQConsumer { Consumer consumer = ONSFactory.createConsumer(consumerProperties); consumer.subscribe(MQConfig.TOPIC, MQConfig.TAG, new MessageListenerImpl()); consumer.start(); - System.out.println("Consumer start success."); + System.out.printf("Consumer start success. %n"); - //等待固定时间防止进程退出 try { Thread.sleep(200000); } catch (InterruptedException e) { diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleOrderConsumer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleOrderConsumer.java index ea5159f..b51a6a0 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleOrderConsumer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/consumer/SimpleOrderConsumer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,16 +35,16 @@ public class SimpleOrderConsumer { consumerProperties.setProperty(PropertyKeyConst.SecretKey, MQConfig.SECRET_KEY); consumerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, MQConfig.NAMESRV_ADDR); OrderConsumer consumer = ONSFactory.createOrderedConsumer(consumerProperties); - consumer.subscribe(MQConfig.ORDER_TOPIC, MQConfig.TAG, new MessageOrderListener() { + consumer.subscribe(MQConfig.ORDER_TOPIC, MQConfig.TAG, new MessageOrderListener() { @Override public OrderAction consume(final Message message, final ConsumeOrderContext context) { - System.out.println(message); + System.out.printf("Received message: %s%n", message); return OrderAction.Success; } }); consumer.start(); - System.out.println("Consumer start success."); + System.out.printf("Consumer start success. %n"); try { Thread.sleep(200000); diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/LocalTransactionCheckerImpl.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/LocalTransactionCheckerImpl.java index f5dbd1a..f21db81 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/LocalTransactionCheckerImpl.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/LocalTransactionCheckerImpl.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,12 +20,11 @@ import org.apache.rocketmq.ons.api.Message; import org.apache.rocketmq.ons.api.transaction.LocalTransactionChecker; import org.apache.rocketmq.ons.api.transaction.TransactionStatus; - public class LocalTransactionCheckerImpl implements LocalTransactionChecker { @Override public TransactionStatus check(Message msg) { - System.out.println("Receive transaction check back request, MsgId: " + msg.getMsgID()); + System.out.printf("Receive transaction check back request, MsgId: %s%n", msg.getMsgID()); return TransactionStatus.CommitTransaction; } } diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/MQTimerProducer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/MQTimerProducer.java index 471b8bd..26a6bf2 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/MQTimerProducer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/MQTimerProducer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +16,6 @@ */ package org.apache.rocketmq.ons.sample.producer; -import java.util.Date; import java.util.Properties; import org.apache.rocketmq.ons.api.Message; import org.apache.rocketmq.ons.api.ONSFactory; @@ -34,7 +34,7 @@ public class MQTimerProducer { producerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, MQConfig.NAMESRV_ADDR); Producer producer = ONSFactory.createProducer(producerProperties); producer.start(); - System.out.println("Producer Started"); + System.out.printf("Producer Started. %n"); for (int i = 0; i < 10; i++) { Message message = new Message(MQConfig.TOPIC, MQConfig.TAG, "MQ send timer message test".getBytes()); @@ -43,9 +43,9 @@ public class MQTimerProducer { try { SendResult sendResult = producer.send(message); assert sendResult != null; - System.out.println(new Date() + " Send mq timer message success! Topic is: " + MQConfig.TOPIC + " msgId is: " + sendResult.getMessageId()); + System.out.printf("Send mq timer message success! Topic is: %s msgId is: %s%n", MQConfig.TOPIC, sendResult.getMessageId()); } catch (ONSClientException e) { - System.out.println(new Date() + " Send mq message failed. Topic is:" + MQConfig.TOPIC); + System.out.printf("Send mq message failed. Topic is: %s%n", MQConfig.TOPIC); e.printStackTrace(); } } diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleMQProducer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleMQProducer.java index e397a00..e3cb192 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleMQProducer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleMQProducer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,8 +16,6 @@ */ package org.apache.rocketmq.ons.sample.producer; - -import java.util.Date; import java.util.Properties; import org.apache.rocketmq.ons.api.Message; import org.apache.rocketmq.ons.api.ONSFactory; @@ -37,16 +36,16 @@ public class SimpleMQProducer { producerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, MQConfig.NAMESRV_ADDR); Producer producer = ONSFactory.createProducer(producerProperties); producer.start(); - System.out.println("Producer Started"); + System.out.printf("Producer Started %n"); for (int i = 0; i < 10; i++) { Message message = new Message(MQConfig.TOPIC, MQConfig.TAG, "mq send transaction message test".getBytes()); try { SendResult sendResult = producer.send(message); assert sendResult != null; - System.out.println(new Date() + " Send mq message success! Topic is: " + MQConfig.TOPIC + " msgId is: " + sendResult.getMessageId()); + System.out.printf("Send mq timer message success! Topic is: %s msgId is: %s%n", MQConfig.TOPIC, sendResult.getMessageId()); } catch (ONSClientException e) { - System.out.println(new Date() + " Send mq message failed! Topic is: " + MQConfig.TOPIC); + System.out.printf("Send mq message failed. Topic is: %s%n", MQConfig.TOPIC); e.printStackTrace(); } } diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleOrderProducer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleOrderProducer.java index dd0b3ae..43ab7f0 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleOrderProducer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleOrderProducer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +16,6 @@ */ package org.apache.rocketmq.ons.sample.producer; -import java.util.Date; import java.util.Properties; import org.apache.rocketmq.ons.api.Message; import org.apache.rocketmq.ons.api.ONSFactory; @@ -35,7 +35,7 @@ public class SimpleOrderProducer { producerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, MQConfig.NAMESRV_ADDR); OrderProducer producer = ONSFactory.createOrderProducer(producerProperties); producer.start(); - System.out.println("Producer Started"); + System.out.printf("Producer Started. %n"); for (int i = 0; i < 10; i++) { Message msg = new Message(MQConfig.ORDER_TOPIC, MQConfig.TAG, "MQ send order message test".getBytes()); @@ -45,9 +45,9 @@ public class SimpleOrderProducer { try { SendResult sendResult = producer.send(msg, shardingKey); assert sendResult != null; - System.out.println(new Date() + " Send mq message success! Topic is: " + MQConfig.ORDER_TOPIC + " msgId is: " + sendResult.getMessageId()); + System.out.printf("Send mq timer message success! Topic is: %s msgId is: %s%n", MQConfig.TOPIC, sendResult.getMessageId()); } catch (ONSClientException e) { - System.out.println(new Date() + " Send mq message failed! Topic is: " + MQConfig.TOPIC); + System.out.printf("Send mq message failed. Topic is: %s%n", MQConfig.TOPIC); e.printStackTrace(); } } diff --git a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleTransactionProducer.java b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleTransactionProducer.java index 4ab6805..4d16d51 100644 --- a/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleTransactionProducer.java +++ b/ons-sample/src/main/java/org/apache/rocketmq/ons/sample/producer/SimpleTransactionProducer.java @@ -1,12 +1,13 @@ -/** - * Copyright (C) 2010-2016 Alibaba Group Holding Limited - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,17 +47,17 @@ public class SimpleTransactionProducer { SendResult sendResult = transactionProducer.send(message, new LocalTransactionExecuter() { @Override public TransactionStatus execute(Message msg, Object arg) { - System.out.println("Execute local transaction and return TransactionStatus."); + System.out.printf("Execute local transaction and return TransactionStatus. %n"); return TransactionStatus.CommitTransaction; } }, null); assert sendResult != null; } catch (ONSClientException e) { - System.out.println(new Date() + " Send mq message failed! Topic is:" + MQConfig.TOPIC); + System.out.printf(new Date() + " Send mq message failed! Topic is: %s%n", MQConfig.TOPIC); e.printStackTrace(); } } - System.out.println("Send transaction message success."); + System.out.printf("Send transaction message success. %n"); } } \ No newline at end of file
