Com.rabbitmq.client.impl.Frame.readFrom (frame.java:95)

Source: Internet
Author: User

RabbitMQ based on Erlang implementations, clients can use Python | Java | Ruby | PHP | C # | Javascript | Go and other languages to implement. Here's a test of the Java language.
Install the RABBITMQ server first.

Maven Dependency
<dependency>        <groupId>com.rabbitmq</groupId>        <artifactId>amqp-client</artifactId> <version>3.0.4</version></dependency><dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version></dependency>
The Java test code is as follows:
Defines the queue endpoint.JavaPublicAbstractClass endpoint{protected channel channel;protected Connection Connection;protected String endpointname;PublicEndPoint (String endpointname)Throws ioexception{This.Endpointname = Endpointname;Create a connection factory connectionfactory factory =NewConnectionFactory ();Hostname of your RABBITMQ server factory.Sethost ("192.168.163.33"); Factory.Setport (5672); Factory.Setusername ("Test"); Factory.SetPassword ("Test");Creating a channel Channel = connection.CreateChannel ();Declaring a queue for the This channel. If queue does not exist,It is created on the server. Channel.Queuedeclare (Endpointname,FalseFalseFalseNULL); }/*** Close channel and connection. Not necessary as it happens implicitly any.*@throws IOException*/PublicvoidClose ()Throws ioexception{This.Channel.Close ();This.Connection.Close (); }}Producer producer.JavaPublicClass ProducerExtends endpoint{PublicProducer (String endpointname)Throws ioexception{Super (Endpointname); }PublicvoidSendMessage (Serializable object)Throws IOException {channel.Basicpublish ("", Endpointname,NULL, Serializationutils.Serialize (object)); } }Consumer queue Queueconsumer.JavaPublicClass QueueconsumerExtends EndPointImplements Runnable, consumer{PublicQueueconsumer (String endpointname)Throws ioexception{Super (Endpointname); }PublicvoidRun () {try {Start consuming messages. Auto acknowledge messages. Channel.Basicconsume (Endpointname,Truethis); }catch (IOException e) {e.Printstacktrace (); } }/*** Called when consumer is registered.*/PublicvoidHandleconsumeok (String consumertag) {System.Out.println"Consumer" +consumertag +"Registered"); }/*** Called when the new message is available.*/PublicvoidHandledelivery (String Consumertag, Envelope env, basicproperties props,Byte[] body)Throws IOException {map map = (HASHMAP) serializationutils.Deserialize (body); System.Out.println"Message number" + map.Get"Message number") +"received."); }PublicvoidHandlecancel (String consumertag) {}PublicvoidHandlecancelok (String consumertag) {}PublicvoidHandlerecoverok (String consumertag) {}PublicvoidHandleshutdownsignal (String Consumertag, shutdownsignalexception arg1) {}}Test case Main.JavaPublicClass Main {PublicMain ()Throws exception{Queueconsumer consumer =NewQueueconsumer ("Queue"); Thread Consumerthread =New Thread (consumer); Consumerthread.Start (); Producer Producer =NewProducer ("Queue");for (int i = 0; i < 100000; i++) {HASHMAP message = new HashMap (); message. put ( "message number", i); Producer.out. println ( "Message number" + I +/** *  @param args *  @throws SQLException  *  @throws IOException  */public span class= "DT" >static void main (string[] args) throws exception{ new main ();}            

Run the report for the following error

Exception in Thread"Main" com.Rabbitmq.Client.Possibleauthenticationfailureexception:possibly caused by authentication failure at COM.Rabbitmq.Client.Impl.Amqconnection.Start (amqconnection.Java:355) at COM.Rabbitmq.Client.ConnectionFactory.Newconnection (connectionfactory.Java:516) at COM.Rabbitmq.Client.ConnectionFactory.Newconnection (connectionfactory.Java:533) at COM.Tony.Test.Endpoint.<init> (EndPoint.Java:) at COM.Tony.Test.Queueconsumer.<init> (Queueconsumer.Java:) at COM.Tony.Test.Test.<init> (test.Java:) at COM.Tony.Test.Test.Main (test.Java:) caused by:com.Rabbitmq.Client.Shutdownsignalexception:connection error; Reason:java.Net.Socketexception:connection Reset at com.Rabbitmq.Utility.Valueorexception.GetValue (valueorexception.Java:) at COM.Rabbitmq.Utility.Blockingvalueorexception.Uninterruptiblegetvalue (blockingvalueorexception.Java:) at COM.Rabbitmq.Client.Impl.Amqchannel$blockingrpccontinuation.Getreply (Amqchannel.Java:343) at COM.Rabbitmq.Client.Impl.Amqchannel.Privaterpc (Amqchannel.Java:216) at COM.Rabbitmq.Client.Impl.Amqchannel.RPC (Amqchannel.Java:202) at COM.Rabbitmq.Client.Impl.Amqconnection.Start (amqconnection.Java:347)...6 morecaused By:java.Net.Socketexception:connection Reset at java.Net.Socketinputstream.Read (Socketinputstream.Java:209) at Java.Net.Socketinputstream.Read (Socketinputstream.Java:141) at Java.Io.Bufferedinputstream.Fill (bufferedinputstream.Java:246) at Java.Io.Bufferedinputstream.Read (Bufferedinputstream.java:265) at Java. io. datainputstream. readunsignedbyte (Datainputstream.288) at Com.rabbitmq.impl. frame. readfrom (Frame.95) at Com.rabbitmq.impl. socketframehandler. readframe (Socketframehandler.131) at Com.rabbitmq.impl. amqconnection$mainloop. run (Amqconnection.515)             

Workaround this or this


Online Rabbit Performance test

Performance testing

You can see the number of millions messages per second, and 2,343 messages waiting in the queue.

Front-end time I also reported on the MQ as the title of the error, when the MQ V-host did not give, I tried "/" and not worthy of the item, but all reported as the problem as shown in the error, after checking for MQ configuration V-host

Com.rabbitmq.client.impl.Frame.readFrom (frame.java:95)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.