Hi We want to transfer files over AMQ and once I wrote a Perl script that uses an external tool Spazio and IBM MQ to do the same. Perl has a STOMP module to interface with AMQ but how can I send a large file without reading it into a variable? I made a test script that can put a small file on an Artemis queue which can be read by a Camel route. But what if the file does not fit in memory?
#!/home/mqm/perl5/bin/perl use strict; use warnings; use File::stat; use Net::STOMP::Client; my $mypath = "/home/mqm/perl2amq"; my $myfile = "pauls_what.bin"; my $stomp = Net::STOMP::Client->new( host => 'artemis', port => '61613 +' ); my $peer = $stomp->peer(); printf("connected to broker %s (IP %s), port %d\n", $peer->host(), $peer->addr(), $peer->port()); $stomp->connect( login => 'jboss', passcode => 'notyourstoknow' ); printf("speaking STOMP %s with server %s\n", $stomp->version(), $stomp->server() || "UNKNOWN"); my $content; open(my $fh, '<', $myfile) or die "cannot open file $myfile"; { local $/; $content = <$fh>; } close($fh); my $stat = stat($myfile); my $mylength = $stat->size; # content-length => $mylength, my $dashhost = "amqclient-source-com"; my $five = "12345"; my $stime = time(); my $my_id = "ID-$dashhost-$five-$stime-2-3"; $stomp->send( destination => "testqueue", CamelFileAbsolutePath => "$mypath/$myfile", CamelFileName => $myfile, CamelFileNameConsumed => $myfile, CamelFileNameOnly => $myfile, CamelFileParent => $mypath, CamelFilePath => "$mypath/$myfile", CamelFileRelativePath => $myfile, breadcrumbId => $my_id, "content-type" => "application/octet-stream", body => $content, ); $stomp->disconnect;

In reply to transferring a large file with STOMP over Artemis AMQ by Paul.Unix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.