-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Allow message_attributes to be set from ActiveJob clients #635
Conversation
Co-authored-by: Tamara Temple <tamara.temple@drip.com>
d425f54
to
b4327f8
Compare
Also how do we get Travis running? |
Update: We have been running this version in our main app for a couple weeks now and have no reported issues. |
I can't really review this now. But I added a form for "recruiting" Shoryuken maintainers. Let me know if you are interested 4a03b64 |
msg = { | ||
message_body: body, | ||
message_attributes: attributes.merge(MESSAGE_ATTRIBUTES) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timbreitkreutz Sorry for taking long to get back on this.
Is it being used when enqueuing a job? MyJob.perform_later(params)
I do miss the ability to send Shoryuken specific params (for example, FIFO params) when using Active Job is this change adding this support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry was on vacation. Will try to get an answer soon :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I don't think there is a way to inject this via perform_later
--unless I'm missing something. This PR was actually aimed more at the middleware layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phstc I was able to test this locally. The proposed changes do not permit specification of message_attributes
when using perform_later
(I've documented that as a separate issue in #646).
Instead, the following can be used to enqueue a message with additional message_attributes
, without overriding the shoryuken_class
attribute.
class AddJob < ActiveJob::Base
def perform(a, b)
puts a + b
end
end
job = AddJob.new 1, 2
AddJob.queue_adapter.enqueue(job, message_attributes: { 'attr' => { string_value: 'myval', data_type: 'String' } })
Everything looks good from a testing perspective, so I think we're good to merge it. Although it doesn't solve #646, it doesn't hinder it and might actually be an important prerequisite.
@timbreitkreutz Thanks so much for your patience on this one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timbreitkreutz If you could rebase on master
, I'd appreciate it. Travis should run correctly after pushing up the rebased version. 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cjlarose !
Fork master has been updated. Merge with squash I believe will result in a single commit to shoryuken repo? |
Thanks! Tests are green. I'll squash merge. |
Whoops. I said I'd squash merge and then immediately forgot. The |
We'd like to be able to access the SQS message attributes from the Shoryuken client code and middleware. Previously, a memoized copy of the needed attributes were used which interfered with middleware when jobs were nested (i.e. ActiveJob clients calling other Active Jobs). In addition, we had to work implement workarounds for metrics and tracing attributes at that level.
The suggestion here is to allow these to be passed in as options which then get used as the starting point. The necessary active job attributes are then overwritten on top of any that are passed in to be sure they function the same as before.
We are open to any suggestions on style, thanks!
Co-authored by @tamouse