This Blog Has Moved!

Right, so yes, five years ago I moved to github pages, and never bothered to redirect any of these pages there. Now I've moved on from there, and... Finally I am using my real domain, . My blog is now at .  See you there!

Strangeloop Disruptor Workshop Materials

On Sunday I gave my very first workshop on the Disruptor.  The aim was to give people some hands-on coding experience using the syntax.  Because time was limited (you can't get people to build an entire application architecture in 2.5 hours) the example is somewhat contrived, and needs a big leap to make it into a proper application context.  But the workshop should:
  1. Give an overview of the Disruptor
  2. Show how to create a simple one producer, one consumer example.
  3. Show how to wire up a parallel event handler
  4. Show how to how (and why) to create a diamond dependency graph.
  5. Extrapolate beyond these very simple examples to something closer to a real world architecture.
Requirements are:
  1. Basic Java skills
  2. Java 7 update 7
  3. (Optionally) IntelliJ.
The slides (not all that useful, I'll grant you, without me talking) are available, and you can download the code.

If you want to work through the examples yourself, start with com.mechanitis.towerdefense.TowerDefence.  The starting point code for the workshop is in package com.mechanitis.towerdefense.  com.mechanitis.towerdefense1 shows a solution to exercise one, com.mechanitis.towerdefense2 to exercise 2 and so forth.  The final package, com.mechanitis.towerdefense4, has some different towers you can play with to see the effects.  They don't really show anything special about the Disruptor, but they were fun to write and are interesting to play with.


  1. Trisha - the session was great, the materials and information were superb!

  2. Hi Trisha:

    Thank you for this perfect demo! I see it now much clearer, how Disruptor can be used! I believe this was missing in the official Disruptor pages.

    I still have two questions:

    1. I don't understand the usecases for complex pipelines. Could you bring perhaps one more situation where it makes sense to have more than the typical Consumers (Persister/Logger, Business Logic, Outgoing Socket) and the typical Producers (Business Logic, Incoming Socket). I thought long and did come up with one pattern where it may make sense: Say we need to calculate orderbooks for 100 symbols, and the orderbook calculation logic takes quite a long time. Then I have the sockets that give me new quotes; and they are then consumed by two orderbook-restoration consumers. And then the business logic (for example calculate a few indicators based on the status of the orderbooks) runs only after the two orderbook consumers have finished. In this case one orderbook-consumer would be configured to process only symbols starting A-M and the second orderbook-consumer would only process symbols starting N-Z. Any other possible uses for complex

    2. Complexity of Data-class in ringbuffer.

    For my example above, then the data-class used inside the ring-buffer will get more and more complex; and I am not sure if this is what should be the case.

    Also if the ring-buffer is only used as a replacement for a queue, then
    the data class will not be optimal. Typically I can imagine that the data
    class would be say a enum DataType{Trade=1, Quote=2, TradingSignal=3}, then
    the data itselv would be in a "object DataLink" which I imagine introduces
    a lot more garbage.

    Did I get the point of this issue? Or am I clueless?

    3. Threading of Producer and Consumer:
    Producers need to manage their own threading; and Consumers run in their
    own thread; BUT the managent of this thread is managed by the Disruptor.
    Now for Producers I may only use one thread, correct? So if I have one
    Thread for each incoming socket, then I need to have as many producers as

    Thank you

    If for example the sockets

    For this reason I would have two order


Post a Comment

Comments have been disabled since this blog is no longer active.

Popular posts from this blog

Dissecting the Disruptor: What's so special about a ring buffer?

Dissecting the Disruptor: Writing to the ring buffer

Dissecting the Disruptor: Demystifying Memory Barriers