Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-4834

Ruby client examples incorrectly handles '--connection-options' option

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.20
    • Future
    • Ruby Client
    • None

    Description

      The 'connection-options' option is incorrectly handled as a string in the example clients, should be handled as a list.

      1. ruby spout.rb --connection-options " {reconnect:True}

        " "q;

        {create:always}

        "
        2013-05-10 04:49:01 [Client] warning Exception received from broker:
        not-found: not-found: Queue not found:

        {reconnect:True}

        (/builddir/build/BUILD/qpid-0.22/cpp/src/qpid/broker/SessionAdapter.cpp:693)
        [caused by 2 \x08:\x01]
        ./../lib/qpid_messaging/session.rb:63:in `createSender': Queue

        {reconnect:True}

        does not exist (MessagingError)
        from ./../lib/qpid_messaging/session.rb:63:in `create_sender'
        from spout.rb:106
        2013-05-10 04:49:01 [Client] warning Connection
        [127.0.0.1:56869-127.0.0.1:5672] closed

      The 'nil' in the option parser looked weird to me, so I did the
      following change to make the option work:

      1. vim spout.rb
      • opts.on(nil, "--connection-options VALUE",
        + opts.on("--connection-options VALUE",

      Following change results in another error, the connection's
      convert_options method expects list not a string:

      1. ruby spout.rb --connection-options " {reconnect:True}

        " "q;

        {create:always}

        "
        ./../lib/qpid_messaging/connection.rb:149:in `convert_options':
        undefined method `each_pair' for "

        {reconnect:True}

        ":String
        (NoMethodError)
        from ./../lib/qpid_messaging/connection.rb:67:in `initialize'
        from spout.rb:103:in `new'
        from spout.rb:103

      I used the following code to fix the issue, which was sufficient for
      my needs (there would be probably a better solution, I guess):

      • options[:connection_options] = conopts
        + options[:connection_options] = {}
        + conopts = conopts.gsub /^{(.*)}$/, '\1'
        + conopts.split(",").each do |x|
        + key,val = x.split(':')
        + options[:connection_options][key]= val

      Packages used:
      ruby gem: qpid_messaging-0.20.2
      also valid for examples on trunk

      Attachments

        Activity

          People

            mcpierce Darryl Pierce
            pematous Petr Matousek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: