Ram,<br><br><div class="gmail_quote">On Fri, Aug 21, 2009 at 8:31 PM, Ram Muthiah <span dir="ltr"><<a href="mailto:ram.muthiah@yahoo.com">ram.muthiah@yahoo.com</a>></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 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>
</div></div></div></blockquote><div><br>A quick perusal of the source code for TestMain indicates quite quickly (and in my opinion, relatively clearly) that the optional first command line parameter is the target host to connect to. Specifying this will change the host that the application connects to.<br>
<br>The below failure, as indicated by the NoClassFoundError, indicates that you're missing apache commons-io, a dependency of the library. You'll need to add that into your classpath in order for the library to work. Alternatively, you could just run the examples with <a href="http://dev.rabbitmq.com">dev.rabbitmq.com</a> as the first parameter.<br>
<br>Paul.<br> </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><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> public static void main(String[] args) {<br> try {<br>
String hostName = (args.length > 0) ? args[0] : "<span style="font-weight: bold;"><a href="http://dev.rabbitmq.com" target="_blank">dev.rabbitmq.com</a></span>";<br> int portNumber = (args.length > 1) ? Integer.parseInt(args[1]) : AMQP.PROTOCOL.PORT;<br>
String queueName = (args.length > 2) ? args[2] : "SimpleQueue";<br><br> ConnectionFactory connFactory = new ConnectionFactory();<br>
Connection conn = connFactory.newConnection(hostName, portNumber);<br><br> final Channel ch = conn.createChannel();<br><br> ch.queueDeclare(queueName);<br><br> QueueingConsumer consumer = new QueueingConsumer(ch);<br>
ch.basicConsume(queueName, consumer);<br> while (true) {<br> QueueingConsumer.Delivery delivery = consumer.nextDelivery();<br> System.out.println("Message: " + new
String(delivery.getBody()));<br> ch.basicAck(delivery.getEnvelope().getDeliveryTag(), false);<br> }<br> } catch (Exception ex) {<br> System.err.println("Main thread caught exception: " + ex);<br>
ex.printStackTrace();<br> System.exit(1);<br> }<br> }<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> at
com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:121)<br> at com.rabbitmq.client.impl.AMQConnection.open(AMQConnection.java:363)<br> at com.rabbitmq.client.impl.AMQConnection.<init>(AMQConnection.java:208)<br>
at com.rabbitmq.client.impl.AMQConnection.<init>(AMQConnection.java:178)<br> at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:165)<br> at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:213)<br>
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:227)<br> at
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:238)<br> 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>
at com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:599)<br> at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:465)<br>Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/input/ProxyInputStream<br>
at java.lang.ClassLoader.defineClass1(Native Method)<br> at java.lang.ClassLoader.defineClass(ClassLoader.java:621)<br> at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)<br> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)<br> at java.net.URLClassLoader.access$000(URLClassLoader.java:56)<br>
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br>
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at
java.lang.ClassLoader.loadClass(ClassLoader.java:252)<br> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)<br> at com.rabbitmq.client.impl.MethodArgumentReader.<init>(MethodArgumentReader.java:70)<br>
at com.rabbitmq.client.impl.AMQImpl.readMethodFrom(AMQImpl.java:5710)<br> at com.rabbitmq.client.impl.AMQCommand$Assembler.handleFrame(AMQCommand.java:275)<br> at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:107)<br>
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:439)<br>Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.input.ProxyInputStream<br> at
java.net.URLClassLoader$1.run(URLClassLoader.java:200)<br> at java.security.AccessController.doPrivileged(Native Method)<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)<br>
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)<br> 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"><div class="im">
<hr size="1"><b><span style="font-weight: bold;">From:</span></b> Paul Jones <<a href="mailto:pauljones23@gmail.com" target="_blank">pauljones23@gmail.com</a>><br><b><span style="font-weight: bold;">To:</span></b> Ram Muthiah <<a href="mailto:ram.muthiah@yahoo.com" target="_blank">ram.muthiah@yahoo.com</a>><br>
<b><span style="font-weight: bold;">Cc:</span></b> <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br></div><b><span style="font-weight: bold;">Sent:</span></b> Thursday, August 20, 2009 11:07:42 AM<div class="im">
<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [rabbitmq-discuss] Working with Java Client<br></div></font><div><div></div><div class="h5"><br>Ram,<br><br><div class="gmail_quote">On Thu, Aug 20, 2009 at 6:40 PM, Ram Muthiah <span dir="ltr"><<a rel="nofollow" href="mailto:ram.muthiah@yahoo.com" target="_blank">ram.muthiah@yahoo.com</a>></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> </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>
</div></div></div></div></div><br>
</div></blockquote></div><br>