Qpid
  1. Qpid
  2. QPID-4479

spout/drain examples fixes and improvements

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.20, 0.21
    • Component/s: None
    • Labels:
      None

      Description

      (From BZ#878940)

      Description of problem:

      It is unable to set message properties with spout.pl, following change needs to be made to fix this issue:

      • $message->getProperties()->{$name} = $value;
        + $message->setProperty($name, $value);

      Below are proposed changes to the spout/drain examples to be more conformable to other clients (c++, python, java), I think it is valuable to have all the client examples working the same way:

      Patch files for both spout.pl/drain.pl can be found in attachment.

      • drain.pl *:

      Drain do not output the message properties in usable form (properties are displayed as a hash), ie:

      1. perl /usr/share/doc/perl-qpid-0.18/examples/drain.pl -c 1 q
        Message(properties=HASH(0x8f1ecc8),content='')

      It also can be useful to display if the message is redelivered as other clients do.

      Proposing following change to fix these issues:
      +sub printProperties {
      + my $h = shift();
      + return qq[{${\(join', ',map"'$_': '$h->{$_}'",keys%$h)}}]
      +}

      • print "Message(properties=" . $message->getProperties() . ",content='";
        + my $redelivered = ($message->getRedelivered) ? "redelivered=True, " : "";
        + print "Message(" . $redelivered . "properties=" . printProperties($message->getProperties()) . ", content='";

      Proposing to set default timeout to 0 (to be more conformable to other clients):

      • my $timeout = 60;
        + my $timeout = 0;

      Proposing to set default messages count to 0 (to be more conformable to other clients)

      • my $count = 1;
        + my $count = 0;
      • both spout.pl/drain.pl *:

      It is good practise to output usage with h/-help options, or if the input is wrong. It is also in place to stop the program execution after the bad input/help request.

      Proposing following change:

      • "connection-options=s" => \ $connectionOptions,
        -);
        -
        -
        -if (! $result) { - print "Usage: perl drain.pl [OPTIONS]\n"; -}

        -
        + "connection-options=s" => \ $connectionOptions,
        + "help|h" => \ &usage
        +) or usage();

      +sub usage

      { + print "Usage: perl drain.pl [OPTIONS]\n"; + exit; +}

      Version-Release number of selected component (if applicable):
      perl-qpid-0.18-1.el6

      Actual results:
      Unable to set message properties with spout.pl, spout/drain behaviour differs from other clients (c++,py,java)

      Expected results:
      Message properties can be set using spout.pl, spout/drain behaviour more concords to other clients

        Activity

        Hide
        Justin Ross added a comment -

        This change was codeveloped by Petr Matousek and Darryl. Approved for 0.20.

        For the discussion, see https://bugzilla.redhat.com/show_bug.cgi?id=878940 .

        Show
        Justin Ross added a comment - This change was codeveloped by Petr Matousek and Darryl. Approved for 0.20. For the discussion, see https://bugzilla.redhat.com/show_bug.cgi?id=878940 .
        Hide
        Darryl L. Pierce added a comment -

        This commit can be found here (it has the BZ number rather than this JIRA reference in the commit message).

        http://svn.apache.org/viewvc?view=revision&revision=1414221

        Show
        Darryl L. Pierce added a comment - This commit can be found here (it has the BZ number rather than this JIRA reference in the commit message). http://svn.apache.org/viewvc?view=revision&revision=1414221

          People

          • Assignee:
            Darryl L. Pierce
            Reporter:
            Darryl L. Pierce
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development