Java: Difference between revisions

From Open Rail Data Wiki
No edit summary
Line 9: Line 9:
         final Client c = new Client(Constants.SERVER, Constants.PORT, Constants.USERNAME, Constants.PASSWORD);
         final Client c = new Client(Constants.SERVER, Constants.PORT, Constants.USERNAME, Constants.PASSWORD);
         System.out.println("Connected");
         System.out.println("Connected");
         System.out.println("Subscribing");
         System.out.println("Subscribing");
         for (final String topic : Constants.TOPICS)
         for (final String topic : Constants.TOPICS)
Line 23: Line 22:
                     });
                     });
         }
         }
         System.out.println("done subscribing");
         System.out.println("done subscribing");
     }
     }
</code>
</code>

Revision as of 20:52, 31 July 2012

Gorizza Stomp library

This code requires the Gozirra Stomp library.

private static void go() throws Exception
   {
       System.out.println("Connecting");
       final Client c = new Client(Constants.SERVER, Constants.PORT, Constants.USERNAME, Constants.PASSWORD);
       System.out.println("Connected");
       System.out.println("Subscribing");
       for (final String topic : Constants.TOPICS)
       {
           System.out.println("  " + topic);
           c.subscribe("/topic/" + topic,
                   new Listener()
                   {
                       public void message(Map map, String s)
                       {
                           processMessage(map, s);
                       }
                   });
       }
       System.out.println("done subscribing");
   }