Example #1
0
  public static void test() throws IOException {
    BrokerConfig config = new BrokerConfig();
    config.setBrokerAddress("127.0.0.1:15555");
    final Broker broker = new SingleBroker(config);

    Caller caller = new Caller(broker, "MyService");

    Message msg = new Message();
    msg.setBody("hello world");
    for (int i = 0; i < 1000000; i++) {
      Message res = caller.invokeSync(msg, 2500);
      System.out.println(res);
    }

    broker.close();
  }
Example #2
0
 public void handle(Message msg, Session sess) throws IOException {
   Email email = Json.fromJson(Email.class, msg.getBodyString());
   try {
     email.send();
   } catch (EmailException e) {
     e.printStackTrace();
   }
 }
Example #3
0
  public static void main(String[] args) throws Exception {
    Dispatcher dispatcher = new Dispatcher();

    for (int i = 0; i < 100000; i++) {
      MessageClient client = new MessageClient("127.0.0.1:80", dispatcher);

      Message req = new Message();
      req.setCmd("hello");
      req.setBody("hello");
      Message res = client.invokeSync(req);
      System.out.println(res);

      client.close();
      System.out.println(">>>" + i);
    }

    dispatcher.close();
  }