[ROCKETMQ-17] Develop a vendor-neutral open standard for distributed messaging: rename Producer to ProducerApp https://issues.apache.org/jira/browse/ROCKETMQ-17
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/a6964048 Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/a6964048 Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/a6964048 Branch: refs/heads/spec Commit: a696404879dd6c2a07b6c831383a98d08a67f8ea Parents: 5668d25 Author: vintagewang <[email protected]> Authored: Wed Dec 28 14:42:54 2016 +0800 Committer: vintagewang <[email protected]> Committed: Wed Dec 28 14:42:54 2016 +0800 ---------------------------------------------------------------------- .../apache/openmessaging/samples/Producer.java | 45 ------------------- .../openmessaging/samples/ProducerApp.java | 46 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/a6964048/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/Producer.java ---------------------------------------------------------------------- diff --git a/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/Producer.java b/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/Producer.java deleted file mode 100644 index a8bbb5d..0000000 --- a/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/Producer.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.openmessaging.samples; - - -import org.apache.openmessaging.MessagingEndPoint; -import org.apache.openmessaging.MessagingEndPointManager; - -import java.nio.charset.Charset; - -public class Producer { - public static void main(String[] args) { - final MessagingEndPoint messagingEndPoint = MessagingEndPointManager.getMessagingEndPoint("openmessaging:rocketmq://localhost:10911/namespace"); - - final org.apache.openmessaging.Producer producer = messagingEndPoint.createProducer(); - - messagingEndPoint.start(); - - producer.start(); - - producer.send(producer.createBytesMessage("HELLO_TOPIC", "HELLO_BODY".getBytes(Charset.forName("UTF-8")))); - - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - @Override - public void run() { - producer.shutdown(); - messagingEndPoint.shutdown(); - } - })); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/a6964048/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/ProducerApp.java ---------------------------------------------------------------------- diff --git a/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/ProducerApp.java b/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/ProducerApp.java new file mode 100644 index 0000000..0182058 --- /dev/null +++ b/spec/code/messaging-user-level-samples/java/src/main/java/org/apache/openmessaging/samples/ProducerApp.java @@ -0,0 +1,46 @@ +/** + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openmessaging.samples; + + +import org.apache.openmessaging.MessagingEndPoint; +import org.apache.openmessaging.MessagingEndPointManager; +import org.apache.openmessaging.Producer; + +import java.nio.charset.Charset; + +public class ProducerApp { + public static void main(String[] args) { + final MessagingEndPoint messagingEndPoint = MessagingEndPointManager.getMessagingEndPoint("openmessaging:rocketmq://localhost:10911/namespace"); + + final Producer producer = messagingEndPoint.createProducer(); + + messagingEndPoint.start(); + + producer.start(); + + producer.send(producer.createBytesMessage("HELLO_TOPIC", "HELLO_BODY".getBytes(Charset.forName("UTF-8")))); + + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + @Override + public void run() { + producer.shutdown(); + messagingEndPoint.shutdown(); + } + })); + } +} \ No newline at end of file
