<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hi Paul,<br><br>I am not running the client in the same machine as the server. I installed rabbitmq in our server. I am testing the PC clients that communicate with rabbitmq server. I left the username and password as it is, so their values are still "guest". However, the hostname is changed, so I am not able to use TestMain out of the box. The documentation should clearly state that runjava.bat com.rabbitmq.examples.TestMain would work only if the broker is installed in the same machine as the client. <br><br>Going to the "stuck" part of my development effort -- I have the following code that is supposed to connect the consumer to the broker. <br><br>package rabbitmq;<br><br>import com.rabbitmq.client.AMQP;<br>import com.rabbitmq.client.Channel;<br>import
 com.rabbitmq.client.Connection;<br>import com.rabbitmq.client.ConnectionFactory;<br>import com.rabbitmq.client.QueueingConsumer;<br><br>public class SimpleConsumer {<br>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String hostName = (args.length &gt; 0) ? args[0] : "<span style="font-weight: bold;">dev.rabbitmq.com</span>";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int portNumber = (args.length &gt; 1) ? Integer.parseInt(args[1]) : AMQP.PROTOCOL.PORT;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String queueName = (args.length &gt; 2) ? args[2] : "SimpleQueue";<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ConnectionFactory connFactory = new ConnectionFactory();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Connection conn = connFactory.newConnection(hostName, portNumber);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final Channel ch = conn.createChannel();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ch.queueDeclare(queueName);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueueingConsumer consumer = new QueueingConsumer(ch);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ch.basicConsume(queueName, consumer);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (true) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueueingConsumer.Delivery delivery = consumer.nextDelivery();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Message: " + new
 String(delivery.getBody()));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ch.basicAck(delivery.getEnvelope().getDeliveryTag(), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (Exception ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Main thread caught exception: " + ex);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ex.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.exit(1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>When I run the above code, I get the following error message: <br><br>Main thread caught exception: java.io.IOException<br>java.io.IOException<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
 com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:121)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection.open(AMQConnection.java:363)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection.&lt;init&gt;(AMQConnection.java:208)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection.&lt;init&gt;(AMQConnection.java:178)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:165)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:213)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:227)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
 com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:238)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at rabbitmq.SimpleConsumer.main(SimpleConsumer.java:48)<br>Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.lang.NoClassDefFoundError: org/apache/commons/io/input/ProxyInputStream<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:599)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:465)<br>Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/input/ProxyInputStream<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.defineClass1(Native Method)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.defineClass(ClassLoader.java:621)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
 java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URLClassLoader.access$000(URLClassLoader.java:56)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URLClassLoader$1.run(URLClassLoader.java:195)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.security.AccessController.doPrivileged(Native Method)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URLClassLoader.findClass(URLClassLoader.java:188)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
 java.lang.ClassLoader.loadClass(ClassLoader.java:252)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.MethodArgumentReader.&lt;init&gt;(MethodArgumentReader.java:70)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQImpl.readMethodFrom(AMQImpl.java:5710)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQCommand$Assembler.handleFrame(AMQCommand.java:275)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:107)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:439)<br>Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.input.ProxyInputStream<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
 java.net.URLClassLoader$1.run(URLClassLoader.java:200)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.security.AccessController.doPrivileged(Native Method)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URLClassLoader.findClass(URLClassLoader.java:188)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClass(ClassLoader.java:252)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)<br><br><br>What I am looking for is complete working example of java code for the client. Simple example like just connecting to the broker and receiving the message (on the consumer side) from the producer. <br><br>Thanks<br>Ram<br><br></div><div style="font-family:
 times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Paul Jones &lt;pauljones23@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Ram Muthiah &lt;ram.muthiah@yahoo.com&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> rabbitmq-discuss@lists.rabbitmq.com<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, August 20, 2009 11:07:42 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [rabbitmq-discuss] Working with Java Client<br></font><br><meta http-equiv="x-dns-prefetch-control" content="off">Ram,<br><br><div class="gmail_quote">On Thu, Aug 20, 2009 at 6:40 PM, Ram Muthiah <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:ram.muthiah@yahoo.com" target="_blank"
 href="mailto:ram.muthiah@yahoo.com">ram.muthiah@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>I feel the examples document needs to be more detailed. Examples page instructs to run           <code>runjava.bat com.rabbitmq.examples.TestMain to run the TestMain class. But, don't we need to change hostname, guest, password, etc before running these classes? <br>
</code></div></div></div></blockquote><div><br>As far as I can see, the scripts default to using localhost and guest/guest. A broker running on the same machine should accept these credentials out of the box.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div><code><span></span><br>I setup the server, I ran some basic python scripts to
 send/receive messages, they work well. I am stuck while using java client. Any help is much appreciated.<br></code></div></div></div></blockquote><div><br>Unfortunately you're going to need to tell us how you're stuck before we can provide any useful assistance.<br>
<br>Paul.<br></div></div>
<meta http-equiv="x-dns-prefetch-control" content="on"></div></div></div><br>

      </body></html>