Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-856 - Support consumersBeforeDispatch and delayBeforeDispatch #2175

Closed

Conversation

michaelandrepearce
Copy link
Contributor

https://issues.apache.org/jira/browse/ARTEMIS-856

This is equivalent to consumersBeforeDispatchStarts and timeBeforeDispatchStarts in ActiveMQ 5.x

http://activemq.apache.org/message-groups.html

This is addressing one of the items on the artemis roadmap: http://activemq.apache.org/activemq-artemis-roadmap.html

@@ -270,6 +271,15 @@

private final QueueFactory factory;

private final AtomicBoolean dispatching = new AtomicBoolean();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic that involves using dispatching and dispatchStartTime could be simplyfied using just dispatchStartTime?
I would use and AtomicLongFieldUpdater for that in case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted that when dispatching the quickest eval is done, thus why the seperate boolean. As it is hot path. Agree could just use != -1 check, memory vs cpu cycle. Let me know your thought

Agree re atomic updater, i can make this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree could just use != -1 check, memory vs cpu cycle

TBH to me are good enough both, but if we can just check !=-1 it would be welcome, even if less readable...
I'm more worried about the writes cost then the reads :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 so after going back to see if i could just use != -1, i remembered why i couldnt it would mean adding a System.currentMillis call on the hot path, which is very costly.

I have though moved to using AtomicUpdaters , though :)

@michaelandrepearce
Copy link
Contributor Author

Fyi i go on annual leave 4pm tomorrow, so if youbcan comment before i can make changes before i leave else it will have to wait 2 weeks

@michaelandrepearce michaelandrepearce force-pushed the ARTEMIS-856 branch 2 times, most recently from dbbb6ff to aae5493 Compare July 10, 2018 15:48
@michaelandrepearce
Copy link
Contributor Author

note: seems test failure is related to #2173

https://issues.apache.org/jira/browse/ARTEMIS-856

This is equivalent to consumersBeforeDispatchStarts and timeBeforeDispatchStarts in ActiveMQ 5.x

http://activemq.apache.org/message-groups.html

This is addressing one of the items on the artemis roadmap: http://activemq.apache.org/activemq-artemis-roadmap.html
@michaelandrepearce
Copy link
Contributor Author

michaelandrepearce commented Jul 24, 2018

@franz1981 @clebertsuconic i will merge in the morning if no further comments

@clebertsuconic
Copy link
Contributor

Ohhh.. nice one.. I just looked at what was the semantics changed.. nice one!!!!

it would be nice to add some docs.. a paragraph would do.

If you don't have time to do it now I will merge it and do it later.. let me know.

* access control
*/
@CallerSensitive
public static <U> AtomicBooleanFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that is a sad that JDK isn't providing this class with a native implementation, but I would use directly AtomicIntegerFiledUpdater or AtomicReferenceFieldUpdater with Boolean values instead.
The reason is that there is an implicit behaviour of any SomethingFiledUpdater that can't be enforced here: the declaration of a volatile Something.
Instead, the real purpose of this class is to treat integer values like boolean ones so I suppose that using a plain statitc util class to convert boolean<->integer will make it simple while avoiding to provide a more complex concurrent util class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 isn't that too much nit picking? :)

I like the work as is.. as anything in life.. it can always be improved.. but the excellent is the enemy of the very good :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franz1981 using Boolean you might as well then just use atomic boolean, which you commented eadlier on and rightly so to use atomic updater. As the point is to save having object reference overheads.

The point of the class is just to make it reusable if else where you want else you end up with lots of dupe code just for all the int to bool logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about the reasons but given that the JVM doesn't trust final fields you won't get the same performance you would have just using the int updater. Given that, I suppose that everything that let it works is ok for me: the PR is well done as always :)

@michaelandrepearce
Copy link
Contributor Author

@clebertsuconic if could merge as is, ill get docs done in another pr but before release if ok

@clebertsuconic
Copy link
Contributor

@michaelandrepearce I created https://issues.apache.org/jira/browse/ARTEMIS-1991 to track the doc.

Marked as blocker just so it appears on the top of the list before release. I'm using that as a marker on what needs to be finished before we release.

clebertsuconic added a commit to clebertsuconic/activemq-artemis that referenced this pull request Jul 25, 2018
@clebertsuconic
Copy link
Contributor

@michaelandrepearce this is broken... can you rebase and check what's happening?

@michaelandrepearce
Copy link
Contributor Author

Ill rebase tomorrow

@clebertsuconic
Copy link
Contributor

this is so weird.. I have no idea what changed.. but I can't build on artemis-features.

Probably the double xsd on tools? I 've tried debugging... and I can't figure out

I will keep trying tomorrow. but if you know anything @michaelandrepearce please let me know.

@michaelandrepearce
Copy link
Contributor Author

@clebertsuconic ill close this as i dont have time today or monday to dedicate further on this, as coming off holiday have a bit of a full plate in work, and ill work offline to see whats going and re-open once i figured it out.

btw trying to ping you on IRC ;)

@clebertsuconic
Copy link
Contributor

Please don’t close it. If you don’t have time I will do it. It’s just I wanted to figure out

Can you reopen please ?

@clebertsuconic
Copy link
Contributor

I already know this is because of AtomicBooleanFieldUpdater. Something is causing confusion on OSGI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants