Disruptor pattern – Java: with or without disruptor

HY,

At present, I am developing a program that takes two values from AMQ queue and performs a series of mathematical calculations on them A topic has been created on the AMQ server to which my program subscribes and received messages through a callback (listener)

Now, as soon as the message arrives, two values are taken from the synchronized descriptive statistics object and added After each addition to the value list, the entire calculation sequence is re executed (which is actually part of the requirement)

The problem I face now is that I sometimes receive one or more messages during the calculation because I use a listener Although synchronized descriptive statistics handles all thread related issues on its own, it adds all wait values to its digital list immediately when locking or other content Although my problem is to add a value, then execute calcls on it, and then execute the second value

The solution I came up with was to use job queues (not AMQ queues) in my program In this way, as long as the calculation ends, the program will look for more work in the queue and continue the corresponding work

Since I'm also looking for efficiency and speed, I think the disruptor framework may be good for this problem and optimized for threading But I'm not sure if it's worth the trouble of implementing disruptor in my application, because regular standard queues may be enough for my purpose

I also want to tell you that there is a lot of data to perform the calculation, and it will continue, and the whole calculation needs to be repeated every time a single value is added in a continuous way So remember efficiency and a lot of data, which data do you think is useful in the long run

Waiting for reply

to greet.

Solution

I will give a typical answer to this question: test first, and then make a decision based on your results

Although you talked about efficiency, you didn't say that performance is a basic requirement If you understand the performance requirements, you can use queues to simulate a simple prototype instead of the basic implementation of the disruptor, and measure the performance of both

If one person is much better than another, that's your answer However, if more effort is required, especially if it does not provide you with the required efficiency, or you do not have any hard performance requirements, then this indicates that the solution is not correct

First measure and then decide according to your results

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>