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

Added ability to add message_properties with variables. #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sophie135
Copy link

When adding message_properties dictionary (message_properties => {"content_type" => "const type"})
You can now use dynamic values from variables {"content_type" => "%{ContentType}"}

Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/

@@ -63,7 +63,7 @@ def multi_receive_encoded(events_and_data)

def publish(event, message)
raise ArgumentError, "No exchange set in HareInfo!!!" unless @hare_info.exchange
local_exchange.publish(message, :routing_key => event.sprintf(@key), :properties => symbolize(@message_properties.merge(:persistent => @persistent)))
local_exchange.publish(message, :routing_key => event.sprintf(@key), :properties => symbolize(@message_properties.merge(:persistent => @persistent), event))
Copy link
Member

Choose a reason for hiding this comment

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

can we revert this change, I don't see a need to log the whole event

Copy link
Author

Choose a reason for hiding this comment

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

I didn't understand what you meant.
I tried to evaluate the value in the {key: value}, so when it's a variable, like {"reply_to" => "%{myReplyTo}"}, the value in rabbit won't be "%{myReplyTo}" but the value of the variable myReplyTo.
I know there is an issue with the commit now (and the reason it didn't passed the tests), that it refers to the value always as a string, and if it's a boolean (like {"persistent" => true}) it will return {"persistent" => "true"}.
I'll fix it. But is there any other things I'm missing?

@sophie135 sophie135 force-pushed the rabbit_message_properties branch 2 times, most recently from 053f4f4 to a0fedb6 Compare January 29, 2018 14:15
When adding message_properties dictionary (message_properties => {"content_type" => "const type"})
You can now use dynamic values from variables {"content_type" => "%{ContentType}"}
@jeslopalo
Copy link

hi @jsvd @sophie135,

is there any plan to release this feature?

It would be very useful to be able to set the priority of the message dynamically.

message_properties => {"priority" => "%{priority}"}

@yaauie
Copy link
Contributor

yaauie commented Nov 21, 2019

@jeslopalo I have revived this feature in the new RabbitMQ Integration Plugin: logstash-plugins/logstash-integration-rabbitmq#9

Since the Integration Plugin requires Logstash 6.5, I'd appreciate your input on backport requirements to get this feature working for you since you contributed.

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

Successfully merging this pull request may close these issues.

4 participants