| 1 | #!/usr/local/bin/perl -w | ||
| 2 | |||
| 3 | # $Id: alvis-pipeline-put.pl,v 1.4 2005/09/30 16:20:37 mike Exp $ | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use IO::File; | ||
| 8 | use Alvis::Pipeline; | ||
| 9 | |||
| 10 | die "Usage: $0 <host> <port>" if @ARGV != 2; | ||
| 11 | my($host, $port) = @ARGV; | ||
| 12 | my $loglevel = 3; ### should be settable from command-line | ||
| 13 | |||
| 14 | my $pipe = new Alvis::Pipeline::Write(host => $host, port => $port, | ||
| 15 | loglevel => $loglevel) | ||
| 16 | or die "can't create write-pipe for host '$host', port '$port': $!"; | ||
| 17 | |||
| 18 | my $count = 1; | ||
| 19 | while (1) { | ||
| 20 | my $xml = <<__EOT__; | ||
| 21 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 22 | <count>This is document number $count</count> | ||
| 23 | __EOT__ | ||
| 24 | $pipe->write($xml); | ||
| 25 | print "Wrote document $count to the pipe\n"; | ||
| 26 | $count++; | ||
| 27 | sleep(int(rand() * 5) + 1); | ||
| 28 | } |