@Test public void test () throws Exception { ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.execute(() -> Main.main(null)); SECONDS.sleep(2); try (Node node = Nodes.singleNode("test@localhost", true)) { Mailbox mailbox = node.mailbox() .build(); Pojo request = new Pojo( mailbox.getPid(), "Artem", 27, true, 543, asList("java", "nim", "elixir"), "developer", singleton("popa"), "some long string...or not", new Boolean[] { true, false, true } ); ErlangTerm requestTerm = TermMapper.serialize(request); mailbox.send("java@localhost", "my_process", requestTerm); ErlangTerm responseTerm = mailbox.receive(20, SECONDS).getBody(); Pojo response = TermMapper.deserialize(responseTerm, Pojo.class); assertThat(response).isEqualTo(request); } }
public static void main(String[] args) { Node node = Nodes.singleNode("java@localhost", true); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm request = mailbox.receive().getBody(); Pojo pojo = TermMapper.deserialize(request, Pojo.class); ErlangPid from = pojo.getSender(); System.out.format("from %s message: %s\n", from, pojo); pojo.setSender(mailbox.getPid()); ErlangTerm response = TermMapper.serialize(pojo); mailbox.send(from, response); node.close(); }
Main { public static void main(String[] args) { Node node = Nodes.singleNode("java@localhost", true); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm request = mailbox.receive().getBody(); Pojo pojo = TermMapper.deserialize(request, Pojo.class); ErlangPid from = pojo.getSender(); System.out.format("from %s message: %s\n", from, pojo); pojo.setSender(mailbox.getPid()); ErlangTerm response = TermMapper.serialize(pojo); mailbox.send(from, response); node.close(); } }
Main { public static void main(String[] args) { Node node = Nodes.singleNode("java@localhost", true); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm request = mailbox.receive().getBody(); Pojo pojo = TermMapper.deserialize(request, Pojo.class); ErlangPid from = pojo.getSender(); System.out.format("from %s message: %s\n", from, pojo); pojo.setSender(mailbox.getPid()); ErlangTerm response = TermMapper.serialize(pojo); mailbox.send(from, response); node.close(); }  }
Main { public static void main(String[] args) { Node node = Nodes.singleNode("java@localhost", true); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm request = mailbox.receive().getBody(); Pojo pojo = TermMapper.deserialize(request, Pojo.class); ErlangPid from = pojo.getSender(); System.out.format("from %s message: %s\n", from, pojo); pojo.setSender(mailbox.getPid()); ErlangTerm response = TermMapper.serialize(pojo); mailbox.send(from, response); node.close(); }  static void main(String[] args); }
Main { public static void main(String[] args) { Node node = Nodes.singleNode("java@localhost", true); Mailbox mailbox = node.mailbox() .name("my_process") .build(); ErlangTerm request = mailbox.receive().getBody(); Pojo pojo = TermMapper.deserialize(request, Pojo.class); ErlangPid from = pojo.getSender(); System.out.format("from %s message: %s\n", from, pojo); pojo.setSender(mailbox.getPid()); ErlangTerm response = TermMapper.serialize(pojo); mailbox.send(from, response); node.close(); }  static void main(String[] args);  }