3737public class FileConsumer {
3838 public static void main (String [] args ) {
3939 Options options = new Options ();
40- options .addOption (new Option ("h" , "host" , true , "broker host" ));
41- options .addOption (new Option ("p" , "port" , true , "broker port" ));
40+ options .addOption (new Option ("h" , "uri" , true , "AMQP URI" ));
4241 options .addOption (new Option ("q" , "queue" , true , "queue name" ));
4342 options .addOption (new Option ("t" , "type" , true , "exchange type" ));
4443 options .addOption (new Option ("e" , "exchange" , true , "exchange name" ));
@@ -50,8 +49,7 @@ public static void main(String[] args) {
5049 try {
5150 CommandLine cmd = parser .parse (options , args );
5251
53- String hostName = strArg (cmd , 'h' , "localhost" );
54- int portNumber = intArg (cmd , 'p' , AMQP .PROTOCOL .PORT );
52+ String uri = strArg (cmd , 'h' , "amqp://localhost" );
5553 String requestedQueueName = strArg (cmd , 'q' , "" );
5654 String exchangeType = strArg (cmd , 't' , "direct" );
5755 String exchange = strArg (cmd , 'e' , null );
@@ -65,8 +63,7 @@ public static void main(String[] args) {
6563 }
6664
6765 ConnectionFactory connFactory = new ConnectionFactory ();
68- connFactory .setHost (hostName );
69- connFactory .setPort (portNumber );
66+ connFactory .setUri (uri );
7067 Connection conn = connFactory .newConnection ();
7168
7269 final Channel ch = conn .createChannel ();
0 commit comments