The simplest and actual example code of LMAX Disruptor
Asked Answered
O

5

19

I wish I can get the simplest possible example code, which will show how to use LMAX disruptor(http://code.google.com/p/disruptor/).

Unfortunately every piece of code is out of date. Does someone know, where can I found small and up to date howto (preferable without DSL)?

Ollayos answered 6/2, 2012 at 22:56 Comment(1)
how many times do i need to downvote straight "link to other websites"????Money
S
15

you can see the example here.

http://code.google.com/p/disruptor/wiki/CodeExampleDisruptor2x

I have done a simple example by using the above wiki. hope this helps you.

Sammiesammons answered 17/2, 2012 at 11:50 Comment(2)
That example code is outdate, the ValueEntry can not find in Disruptor 2.10, where can find the newest Disruptor example code, if 2.8+ is best! Thanks!Dancer
ValueEvent is not a disruptor library class. It your class which is use to "hold" your actual event or message. The event factory is then use to pre-create instances of ValueEvent and put on the ring buffer. When your message or event comes in, you get one of the instances created, you set your message on it and say publish. Then ring buffer dispatches it to the handlers.Nanananak
S
22

Here is a simple, runnable, example of how to use the Disruptor library. Example is written in Java using version 2.10.4 of the Disruptor library.

https://github.com/trevorbernard/disruptor-examples

Shelba answered 24/1, 2013 at 4:59 Comment(1)
excellent example. i got caught out passing the ValueEvents between threads not realising that they are recycled by the buffer. I have sent you a pull request with some comments to that effect so that folks can learn from my mistake.Richter
S
15

you can see the example here.

http://code.google.com/p/disruptor/wiki/CodeExampleDisruptor2x

I have done a simple example by using the above wiki. hope this helps you.

Sammiesammons answered 17/2, 2012 at 11:50 Comment(2)
That example code is outdate, the ValueEntry can not find in Disruptor 2.10, where can find the newest Disruptor example code, if 2.8+ is best! Thanks!Dancer
ValueEvent is not a disruptor library class. It your class which is use to "hold" your actual event or message. The event factory is then use to pre-create instances of ValueEvent and put on the ring buffer. When your message or event comes in, you get one of the instances created, you set your message on it and say publish. Then ring buffer dispatches it to the handlers.Nanananak
P
12

There is an official sample application on github now: Getting-Started

Physique answered 4/4, 2014 at 13:35 Comment(0)
L
3

Sharing an example with multiple publishers and chained handlers, this uses their latest available dsl api format https://web.archive.org/web/20140325163503/http://vijayrc.com/vectorclocks/post/thread3

[EDIT 2022-08-29]:

Link was outdated and is not active. Since the answer is good,redirecting to answer via waybackmachine.

Lactation answered 4/2, 2014 at 0:29 Comment(0)
T
0

I have shared example here, I hope it helps.

This question might be duplicate of

Disruptor helloworld example

Tittletattle answered 14/1, 2014 at 8:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.