Environment: CentOS6.4
Erlang must be installed
Go to the official website first download
Under Linux source version otp_src_18.1
And then./configure will make a small mistake. makefile:248:/usr/local/otp_src_18.1/make/x86_64-unknown-linux-gnu/otp_ded.mk:no such file or Directory Error:no curses library functions found
Then you need to install sudo yum install ncurses-devel.x86_64
And then continue./configure
Make
Make install
All right
Next install the very inconvenient RABBITMQ
Also the official website download version rabbitmq_server-3.5.6
Then unzip
CD rabbitmq_server-3.5.6
Start SH sbin/rabbitmq-server
Help SH Sbin/rabbitmqctl
SH sbin/rabbitmqctl add_user hyy hyy
SH sbin/rabbitmqctl set_permissions-p/hyy ". *" ". *" ". *"
And then the very simple Java code of the other to go to the official website to see it
Send side:
ImportCom.rabbitmq.client.connection;importCom.rabbitmq.client.channel;importcom.rabbitmq.client.connectionfactory;/** * @author Blazer He * @__date November 9, 2015 */public class Send {private fi nal static String queue_name = "Hello"; public static void Main (string[] args) throws Exception {connectionfactory factory = new connectionfactory (); FAC Tory.sethost ("192.168.0.57"); Factory.setusername ("Hyy"); Factory.setpassword ("hyy"); Factory.setvirtualhost ("/"); Factory.setport (5672); Connection Connection = factory.newconnection (); Channel channel = Connection.createchannel (); Channel.queuedeclare (Queue_name, False, False, false, null); String message = "Hello world!" ; Channel.basicpublish ("", queue_name, null, Message.getbytes ()); System.out.println ("[X] Sent '" + Message + "'"); Channel.close (); Connection.close (); }}
Receiving end:
Import Java.util.date;import Com.rabbitmq.client.channel;import Com.rabbitmq.client.connection;import Com.rabbitmq.client.connectionfactory;import Com.rabbitmq.client.queueingconsumer;public class Consume {private Final static String queue_name = "Hello"; public static void Main (string[] argv) throws Exception {ConnectionFactory factory = new ConnectionFactory (); Factory.sethost ("192.168.0.57"); Factory.setusername ("Hyy"); Factory.setpassword ("Hyy"); Factory.setvirtualhost ("/"); Connection Connection = Factory.newconnection (); Channel channel = Connection.createchannel (); Channel.queuedeclare (Queue_name, False, False, false, NULL); SYSTEM.OUT.PRINTLN ("[*] waiting for messages. To exit Press CTRL + C "); Queueingconsumer consumer = new Queueingconsumer (channel); Channel.basicconsume (Queue_name, true, consumer); while (true) {Queueingconsumer.delivery Delivery = Consumer.nextdelivery (); String message = new String (Delivery.getbody ()); System.out.println (New Date () + "[x] Received '" + Message + "'"); } }}
Well, the preliminary can be run up, there are more features need to go deep.
RABBITMQ Installation with Hello word!