lizhiboo commented on issue #3288: URL: https://github.com/apache/rocketmq/issues/3288#issuecomment-904582948
> **BUG REPORT** > > 1. Please describe the issue you observed: > Producer always fails while sending first message. > 2. How to reproduce it : > Running the official examples: > `.\bin\tools.sh org.apache.rocketmq.example.quickstart.Producer` > 3. Please tell us about your environment: > > * java version 1.8.0_271 > * macos 10.13.1 > * rocketmq 4.9.0 > > 1. Other information (e.g. detailed explanation, logs, related issues, suggestions how to fix, etc): > I noticed that there has been several issues linked to this bug: [#1113](https://github.com/apache/rocketmq/issues/1113) , [#1651](https://github.com/apache/rocketmq/issues/1651). However, i have a simple sulution to solve them. As we know, MessageClientIDSetter would call **UtilAll.getPid** in class loading, that's the main reason producer timeouts. Actually, **producer.start** have already called **UtilAll.getPid** , we could cache the result to avoid duplicate calls. > > ``` > public class UtilAll { > ....... > ....... > final static String HOST_NAME = ManagementFactory.getRuntimeMXBean().getName(); // format: "pid@hostname" > > public static int getPid() { > try { > return Integer.parseInt(HOST_NAME.substring(0, HOST_NAME.indexOf('@'))); > } catch (Exception e) { > return -1; > } > } > } > ``` > > I have test it , and it works well. Is the error timeout ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
