rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ding...@apache.org
Subject [rocketmq] branch graalvm updated: Modify for building native image
Date Wed, 03 Apr 2019 12:44:54 GMT
This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch graalvm
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/graalvm by this push:
     new 9de6cb7  Modify for building native image
9de6cb7 is described below

commit 9de6cb78bab4c791ee2bdba6130606cb61b562d9
Author: cengfeng lzy <cengfeng.lzy@alibaba-inc.com>
AuthorDate: Wed Apr 3 16:58:27 2019 +0800

    Modify for building native image
---
 client/pom.xml                                     | 32 ++++++++++++++++++
 .../java/org/apache/rocketmq/client/Producer.java  | 38 ++++++++++++++++++++++
 .../apache/rocketmq/client/log/ClientLogger.java   |  5 +++
 client/svm.sh                                      | 21 ++++++++++++
 pom.xml                                            |  1 +
 5 files changed, 97 insertions(+)

diff --git a/client/pom.xml b/client/pom.xml
index 35908f2..afa47c0 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -63,4 +63,36 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+<build>
+<plugins>
+    <plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<version>2.4.1</version>
+				<configuration>
+					<!-- get all project dependencies -->
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+					<!-- MainClass in mainfest make a executable jar -->
+					<archive>
+					  <manifest>
+						<mainClass>org.apache.rocketmq.client.Producer</mainClass>
+					  </manifest>
+					</archive>
+
+				</configuration>
+				<executions>
+				  <execution>
+					<id>make-assembly</id>
+                                        <!-- bind to the packaging phase -->
+					<phase>package</phase> 
+					<goals>
+						<goal>single</goal>
+					</goals>
+				  </execution>
+				</executions>
+			</plugin>
+</plugins>
+</build>
 </project>
diff --git a/client/src/main/java/org/apache/rocketmq/client/Producer.java b/client/src/main/java/org/apache/rocketmq/client/Producer.java
new file mode 100644
index 0000000..6751d40
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/Producer.java
@@ -0,0 +1,38 @@
+/*
+Main entry for building native image
+*/
+package org.apache.rocketmq.client;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import io.netty.handler.logging.LoggingHandler;
+import io.netty.handler.logging.LogLevel;
+
+public class Producer {
+    private static final LoggingHandler log = new LoggingHandler(LogLevel.DEBUG);
+    public static void main(String[] args) throws MQClientException, InterruptedException
{
+
+        DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
+        producer.start();
+
+        for (int i = 0; i < 128; i++)
+            try {
+                {
+                    Message msg = new Message("TopicTest",
+                        "TagA",
+                        "OrderID188",
+                        "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+                    SendResult sendResult = producer.send(msg);
+                    System.out.printf("%s%n", sendResult);
+                }
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        producer.shutdown();
+    }
+}
diff --git a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
index c62b385..1903903 100644
--- a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
+++ b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
@@ -71,9 +71,14 @@ public class ClientLogger {
 
         Layout layout = LoggingBuilder.newLayoutBuilder().withDefaultLayout().build();
 
+/*
         rocketmqClientAppender = LoggingBuilder.newAppenderBuilder()
             .withRollingFileAppender(logFileName, maxFileSize, maxFileIndex)
             .withAsync(false, queueSize).withName(ROCKETMQ_CLIENT_APPENDER_NAME).withLayout(layout).build();
+*/
+        rocketmqClientAppender = LoggingBuilder.newAppenderBuilder()
+            .withConsoleAppender("System.out")
+            .withName(ROCKETMQ_CLIENT_APPENDER_NAME).withLayout(layout).build();
 
         Logger.getRootLogger().addAppender(rocketmqClientAppender);
     }
diff --git a/client/svm.sh b/client/svm.sh
new file mode 100755
index 0000000..5a09433
--- /dev/null
+++ b/client/svm.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+SVM_OPT="--allow-incomplete-classpath --report-unsupported-elements-at-runtime"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=com.alibaba.fastjson.serializer.JodaCodec"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.util.BouncyCastleSelfSignedCertGenerator"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.JdkNpnSslEngine"
+SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.JdkAlpnSslEngine"
+# testing
+#SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.util.SelfSignedCertificate"
+#SVM_OPT="${SVM_OPT} --delay-class-initialization-to-runtime=io.netty.handler.ssl.util.ThreadLocalInsecureRandom"
+SVM_OPT="${SVM_OPT} --rerun-class-initialization-at-runtime=io.netty.handler.ssl.util.SelfSignedCertificate"
+SVM_OPT="${SVM_OPT} --rerun-class-initialization-at-runtime=io.netty.handler.ssl.util.ThreadLocalInsecureRandom"
+SVM_OPT="${SVM_OPT} --enable-url-protocols=http"
+
+
+WORKDIR=`pwd`
+CONFIG_OPT=" -Dio.netty.noUnsafe=true -H:+ReportExceptionStackTraces --allow-incomplete-classpath"
+#native_image=/home/cengfeng.lzy/GraalDev/graal/vm/mxbuild/linux-amd64/GRAALVM_LIBGRAAL/graalvm-libgraal-1.0.0-rc15-dev/bin/native-image
+native_image=~/tools/graalvm-ce-1.0.0-rc14/bin/native-image
+$native_image  $CONFIG_OPT $SVM_OPT -jar target/rocketmq-client-4.4.1-SNAPSHOT-jar-with-dependencies.jar
diff --git a/pom.xml b/pom.xml
index bb83a16..d96dfbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,7 @@
     </issueManagement>
 
     <properties>
+        <checkstyle.skip>true</checkstyle.skip>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 


Mime
View raw message