Successfully reported this slideshow.
Your SlideShare is downloading. ×

Stream-style messaging development with Rabbit, Active, ZeroMQ & Apache Kafka by Vyacheslav Lapin

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 46 Ad

Stream-style messaging development with Rabbit, Active, ZeroMQ & Apache Kafka by Vyacheslav Lapin

Download to read offline

Application performance problems traditionally solving by tuning, but what we tune in most cases? We tune DB, AS or client-side logic, right? But we usually forget about speed of message-sending mechanisms our apps use - what if our bottleneck is exactly there? In message-layer we traditionally use JMS, XML/SOAP and JSON, but is it really fast and channel capacity-safe? In that presentation we will talk about tuning of messaging systems - a modern compact formats, like MsgPack and CBOR as alternative of JSON and XML/SOAP, a modern open-source JMS-alternatives: Rebbit, Active, ZeroMQ and Apache Kafka. I`ll show you how to use it with Java 8 Stream API by real-life example to make your code short, expressive and simple to modification and support!

Application performance problems traditionally solving by tuning, but what we tune in most cases? We tune DB, AS or client-side logic, right? But we usually forget about speed of message-sending mechanisms our apps use - what if our bottleneck is exactly there? In message-layer we traditionally use JMS, XML/SOAP and JSON, but is it really fast and channel capacity-safe? In that presentation we will talk about tuning of messaging systems - a modern compact formats, like MsgPack and CBOR as alternative of JSON and XML/SOAP, a modern open-source JMS-alternatives: Rebbit, Active, ZeroMQ and Apache Kafka. I`ll show you how to use it with Java 8 Stream API by real-life example to make your code short, expressive and simple to modification and support!

Advertisement
Advertisement

More Related Content

Similar to Stream-style messaging development with Rabbit, Active, ZeroMQ & Apache Kafka by Vyacheslav Lapin (20)

Advertisement

More from JavaDayUA (20)

Recently uploaded (20)

Advertisement

Stream-style messaging development with Rabbit, Active, ZeroMQ & Apache Kafka by Vyacheslav Lapin

  1. 1. 1 Stream-style messaging development in Java The NoJMS way October 1, 2015
  2. 2. 2 Problems of traditional way Integration system working is…
  3. 3. 3 Problems of traditional way Integration system working is…
  4. 4. 4 Problems of traditional way Integration system working is…
  5. 5. 5 Problems of traditional way Integration system working is…
  6. 6. 6 Problems of traditional way «There's no such thing as problems, Mr. Green, only situations...» Avi, «Revolver»
  7. 7. 7 Problems of traditional way - Architecture Internet/Intranet Application Server Cluster Database Cluster
  8. 8. 8 Problems of traditional way - Architecture Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster
  9. 9. 9 Problems of traditional way - Architecture Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster … Second another application Server Cluster
  10. 10. 10 Problems of traditional way - Architecture Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster … Second another application Server Cluster
  11. 11. 11 Problems of traditional way - Architecture Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster … Second another application Server Cluster
  12. 12. 12 Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster … Second another application Server Cluster Problems of traditional way - Architecture
  13. 13. 13 Internet/Intranet Application Server Cluster Database Cluster First another application Server Cluster … Second another application Server Cluster Problems of traditional way - Architecture
  14. 14. 14 Problems of traditional way «Actually, the cause of computer revolution is not that calculator become faster and get a lot of memory, get possibility to show as advanced graphics, and so on; but that cause is that computer can connect to another computer. So, computer is not, as usually described, the result of calculator evolution – it`s result of telephone evolution!» Andrey Verbitsky, «SoftwarePeople 2009»
  15. 15. 15 Problems of traditional way
  16. 16. 16 Problems of traditional way WSDL/SOAP web-services (XML)1
  17. 17. 17 Problems of traditional way WSDL/SOAP web-services (XML)1 RESTful web-services (JSON)2
  18. 18. 18 Problems of traditional way WSDL/SOAP web-services (XML)1 RESTful web-services (JSON)2 JMS (Java standard Serialization)3
  19. 19. 19 1. Messages size Problems of traditional way - WSDL/SOAP web-services
  20. 20. 20 1. Messages size 2. Validation via schema Problems of traditional way - WSDL/SOAP web-services
  21. 21. 21 1. Messages size 2. Validation via schema 3. Synchronous model Problems of traditional way - WSDL/SOAP web-services
  22. 22. 22 1. Messages size 2. Validation via schema 3. Synchronous model 4. HTTP(S) Problems of traditional way - WSDL/SOAP web-services
  23. 23. 23 1. Messages Size Problems of traditional way – RESTful/JSON web-services
  24. 24. 24 1. Messages Size 2. Validation? Problems of traditional way – RESTful/JSON web-services
  25. 25. 25 1. Messages Size 2. Validation? 3. Synchronous model Problems of traditional way – RESTful/JSON web-services
  26. 26. 26 1. Messages Size 2. Validation? 3. Synchronous model 4. HTTP(S) Problems of traditional way – RESTful/JSON web-services
  27. 27. 27 1. Java only! Problems of traditional way – JMS
  28. 28. 28 1. Java only! 2. Messages Size Problems of traditional way – JMS
  29. 29. 29 1. Java only! 2. Messages Size 3. Lots of code (except JMS 2.0 in JEE7) Problems of traditional way – JMS
  30. 30. 30 1. Java only! 2. Messages Size 3. Lots of code (except JMS 2.0 in JEE7) 4. Lost messages Problems of traditional way – JMS
  31. 31. 31 1. Java only! 2. Messages Size 3. Lots of code (except JMS 2.0 in JEE7) 4. Lost messages 5. Duplicates Problems of traditional way – JMS
  32. 32. 32 1. Enterprise Integration Patterns 2. Apache Camel 3. Spring Integration Modern alternatives
  33. 33. 33 Modern alternatives – Apache Camel @Override public void configure() throws Exception { from("direct:start") .split().method("sectionRequestSplitterBean", "split") .aggregationStrategy(new ReportAggregationStrategy()) .transform().method("sectionRequestToXMLBean", "transform") .to(serviceURL) .transform().method("sectionResponseXMLToSectionBean", "transform"); } public void setServiceURL(String serviceURL) { this.serviceURL = serviceURL; }
  34. 34. 34 Modern alternatives
  35. 35. 35 1. File Transfer 2. Shared Database 3. Remote Procedure Call 4. Messaging Modern alternatives
  36. 36. 36 Problems of coding 1. Synchronous vs Asynchronous 2. Systems Integration or Distributed System? 3. Do we really need a Bus (Mediator)? 4. Back pressure (Reactive Streams – Erlang, Scala, Java) Modern alternatives
  37. 37. 37 1. http://queues.io (~26 decisions) 2. Local BlockingQueue (“seda” in Apache Camel, JdbcChannelMessageStore in Spring Integration) 3. ZooKeeper 4. JCache (Hazelcast) 5. In-memory NoSQL DB (Redis, DertyDB,…) 6. AMQP (ActiveMQ, RabbitMQ) 7. ZeroMQ 8. Amazon SQS 9. Apache Kafka (ZooKeeper inside!) Modern alternatives
  38. 38. 38 Modern alternatives - AMQP (ActiveMQ, RabbitMQ)
  39. 39. 39 Modern alternatives – Apache Kafka
  40. 40. 40 Modern alternatives – Apache Kafka 1. Shared write-ahead log • partitions
  41. 41. 41 Modern alternatives – Apache Kafka
  42. 42. 42 Stream-style code
  43. 43. 43 Stream-style code @Autowired ParametrizedConsumer<OneFieldBean> simpleAmqpReceiver; @Test public void priyomSoobshcheniy() throws Exception { simpleAmqpReceiver.objectStream(OneFieldBean.class) .forEach(object -> out.println(object.getS())); }
  44. 44. 44 Stream-style code private static int ITERATIONS_NUMBER = 1_000; @Autowired private Sender<OneFieldBean> sender; private Benchmark benchmark = new Benchmark(out::println); @Test public void prostaiaPosilkaSoobshcheniy() throws Exception { benchmark.benchmarkOperation(() -> { for (int i = 1; i < ITERATIONS_NUMBER; ) sender.sendMessage(new SimpleOneFieldBean().setS("тест " + i++)); return "done!"; }, "Послано за (сек.): "); }
  45. 45. 45 Stream-style code private static int ITERATIONS_NUMBER = 1_000; @Test public void posilkaSoobshcheniyCherezStream() { benchmark.benchmarkOperation(() -> { sender.streamSending( new Iterator<OneFieldBean>() { AtomicInteger i = new AtomicInteger(0); @Override public boolean hasNext() { return i.get() < ITERATIONS_NUMBER; } @Override public OneFieldBean next() { return new SimpleOneFieldBean().setS("тест " + i.getAndIncrement()); } } ); return "done!"; }, "Послано за (сек.): "); }
  46. 46. 46 Stream-style code @POST @Produces({“application/x-msgpack; qs=1”, “application/json; qs=0.75”}) public Order getOrder() { // … }

×