Recently, we implemented distributed services for the company and sent messages through activemq. The messages are encapsulated into an object that implements serialization and sent by sending objectmessage, when receiving the message, it is found that only one message is sent, but it appears that the message has been received n times in the listener log. However, when reading the log of the sender, the message is actually sent only once, and anotherCodeIt is normal for the Branch to send instances of the same class. Then, let's take a look. In the wrong code branch, a variable in the class instance has no value, set the value. As follows:
// Branch with an error <br/> objactivemq O1 = new objactivem (); <br/> o1.n1 = "11111"; <br/> o1.n2 = "22222 "; <br/> // N3 is not set here </P> <p> // correct code branch <br/> objactivemq O2 = new objactivem (); <br/> o1.n1 = "AAAAA"; <br/> o1.n2 = "bbbbb"; <br/> // The N3 value is set here <br/> 01. n3 = "cccccc"; <br/>