Comments (8)
Hi folks!
Here's the suggestion to provide message attributes using the metadata
field:
The new configuration will accept:
producers: [
default: [
module: {BroadwaySQS.Producer,
queue_name: "my_queue",
metadata: [:message_id, :receipt_handle]
}
]
]
Where metadata
is a list of attributes to be retrieved. Then, you can access the attributes via message.metadata
:
def handle_message(_, message, _) do
IO.inspect(message.metadata.message_id, label: "Msg id")
message
end
The list of available attributes should be defined and documented by the client. On SQS, we'll start with: :message_id
, :receipt_handle
, :attributes
and :message_attributes
. We'll also take a look at RabbitMQ to decide which group of attributes we'll make available and how. @narrowtux, in case you already have suggestions, please let us know.
@dokie, with this change, it's most likely that will revert this commit since both attributes from the receipt will already be available in our new metadata field.
I'll start to work on this sometime this week so any feedback/suggestion is more than welcome.
-marlus
from broadway.
@gvaughn that's exactly suggestion 1. We expose :message_attribute_names
and :attribute_names
in the :client_opts
so it can be forward to the server. Then we treat the response and extract those values and add them to the new metadata
field, along with message_id
, receipt_handle
and md5_of_body
. The data
field of the Message
struct will remain unchanged and represents the body
, the metadata
will hold all other values. The only difference from the original proposal is that we're not adding a :metadata
option anymore, we're adding only the metadata
field to the Message
struct.
from broadway.
Same thing would be interesting for the RabbitMQ producer as well
from broadway.
I recommend you also include message_attributes
SQS considers them different.
Edit: I just noticed which Repo I clicked to. This might be confusing with the SQS terminology. Perhaps metadata
is what you'd want to call it in the Message struct level?
from broadway.
Yes, definitely. We've discussed this earlier today but I forgot to update the title :)
from broadway.
for RabbitMQ I only ever needed the routing key - I'll have a look at the other metadata you can receive there
from broadway.
In order to retrieve any of the attributes and/or message attributes, I'll need to pass :attribute_names
and/or :message_attribute_names
to ExAws.SQS.receive_message/2
. Consequently, in order to keep the API as suggested before, I would need to pass both of those options as :all
, which is definitely undesirable since it will increase data traffic unnecessarily for most cases.
Suggestion 1
Instead of creating a new option :metadata
, we could expose :attribute_names
and :message_attribute_names
to the user. The values, however, could still be set on the metadata
field of the %Message{}
as originally planned. I would also always add message_id
, receipt_handle
and md5_of_body
to the metadata since they are always returned by the SQS service.
Suggestion 2
We don't set the :data
field with the body but with the whole message coming from the server. This would be a breaking change and it will make the metadata
field useless when working with the SQS client. The whole message would look like this:
%{
body: "Mensagem 9",
message_id: "...",
receipt_handle: "..."
md5_of_body: "...",
attributes: %{
"approximate_first_receive_timestamp" => "...",
"approximate_receive_count" => 1,
"sender_id" => "...",
"sent_timestamp" => "..."
},
message_attributes: %{
"TestStringAttribute" => %{
binary_value: "",
data_type: "String",
name: "TestStringAttribute",
string_value: "A test",
value: "A test"
}
}
}
Personally, I would go with suggestion 1. Thoughts?
from broadway.
@msaraiva I had expected to see :message_attribute_names
and :attribute_names
inside the :client_opts
given to the SQSClient. As long as those are validated and handled properly, SQS will include the data in the results. The main issue in the Broadway project is to have a place in the Message
to put them when the SQSClient does wrap_received_messages
from broadway.
Related Issues (20)
- Support hot-reloads to scale stages HOT 2
- 1->n message processing HOT 3
- Possibility to update Pipeline :context ? HOT 1
- Allow use of nimble_options 0.4.0 HOT 2
- [Question] how am i able to update a message in handle_failed and send to another batcher? HOT 1
- How to stop a Broadway Kafka pipeline? HOT 1
- Make producer module a keyword list to ease configuration management? HOT 6
- Broadway.update_rate_limit doesn't reset the counter/interval right away HOT 3
- NoopAcknowledger fails with ack key being set HOT 7
- Disable automatic call to handle_batch/4 HOT 2
- [Question] Creating a Broadway Message struct for testing?
- Telemetry distinguish between Producer metrics HOT 2
- Expected Behavior on Startup? HOT 4
- [docs] The `Broadway.test_batch` example doesn't work with Broadway 1.0.3 HOT 3
- Dialyzer error on ack_immediately/1 HOT 3
- Broadway v1.0.4 Broadway.NoopAcknowledger returns NoopAcknowledger instead of Broadway.NoopAcknowledger HOT 1
- Add `terminate/3` callback HOT 11
- Oban producer HOT 3
- Allow support for Nimble Options 1.0 HOT 5
- Request for MQTT support in Elixir Broadway HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broadway.