[rabbitmq-discuss] Send message to rabbit server?

Nguyen Mau Quoc Hoan nmqhoan at gmail.com
Wed Nov 16 12:20:47 GMT 2011


Hi. I'm very interested in using rabbitmq. I've tried all the examples in
Rabbit website and its work.Now I want to do something further but I could
not know how to do it.I installed the rabbitmq server in one computer
(rabbit server computer) and I will user another computer as a client to
push the message to rabbit server. What should I need to configure in my
client java code?
Something like this:
  public static void main(String[] argv) throws Exception {

    ConnectionFactory factory = new ConnectionFactory();
>     factory.setHost("10.2.17.66:4369");  (it's not localhost anymore,
> intead of this, the host has to be the server address and rabbit port
> number)
>     Connection connection = factory.newConnection();
>     Channel channel = connection.createChannel();
>
>     channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
>     String message = "Hello world";
>
>     channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes());
>     System.out.println(" [x] Sent '" + message + "'");
>
>     channel.close();
>     connection.close();
>   }
>

I tried but it didn't work.What should I do?
Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111116/3fcb7f83/attachment.htm>


More information about the rabbitmq-discuss mailing list