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

Rabbitmq output plugin : dynamic values on headers not working as type is Hash not String #42

Open
DIFRIN opened this issue Feb 2, 2021 · 3 comments

Comments

@DIFRIN
Copy link

DIFRIN commented Feb 2, 2021

constant_properties = template.reject { |_,v| templated?(v) }
With this headers attributs of message_properties will fall all time in the constant_properties because it's not of type string

A Solution could be to extract constant_properties[:headers] then do the same as the variable_properties and reseting it in constant_properties before freezing. Something like

`
def buildHeaders(event)

      if @constant_properties[:headers]

        constant_headers = @constant_properties[:headers].reject { |_, v| templated?(v) }
        variable_headers = @constant_properties[:headers].select { |_, v| templated?(v) }

        headers = variable_headers.each_with_object(constant_headers.dup) do |(k, v), memo|
          memo.store(k, event.sprintf(v))
        end

        @constant_properties[:headers] = headers
        @constant_properties.freez
      end
    end`

@yaauie could you help us fix this issue ? Thank you in advance

@DIFRIN DIFRIN changed the title Rabbitmq output plugin : dynamic values on headers not working as type is Hash and not String Rabbitmq output plugin : dynamic values on headers not working as type is Hash not String Feb 2, 2021
@gkoudjou
Copy link

gkoudjou commented Feb 4, 2021

Hi,

I've open roughly the same issue some months ago --> #27

Thanks for the fix and great job for the plugin

@bahrar
Copy link

bahrar commented Feb 4, 2021

Hello
I encountered exactly the same problem on 7.1.0 and 7.1.1 versions :
headers map values ​​(properties -> headers -> field value) are not templated
(only properties fields of type string are templated)

example to reproduce:
input: id-var="id-value"

output{
      rabbitmq {
          exchange => "my-exchange"
          exchange_type => "topic"
          user => "my-user"
          password => "my-password"
          key => "%{[@metadata][routing_key]}"
          host => "my-host"
          port => 35672
          properties => {
            headers => {
               id => "%{[id-var]}"
               version => "1.0"
             }
          }
      }
}

expected message body in rabbitmq :
{"id" : "id-value", "date" : "2021-02-03-15.31.32.708295"}
but was :
{"id" : "%{[id-var]}", "date" : "2021-02-03-15.31.32.708295"}

Thank you in advance for the fix

@DIFRIN
Copy link
Author

DIFRIN commented Feb 17, 2021

@jsvd @yaauie coud you please have a look into this issue.

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

No branches or pull requests

3 participants