#!/usr/bin/perl # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------------ # # sample publisher # use strict; use warnings; use Net::STOMP::Client; use Time::HiRes qw(time); our(%Option, $Conn, $Start); $Option{user} = $ENV{STOMP_USER} || "admin"; $Option{password} = $ENV{STOMP_PASSWORD} || "password"; $Option{host} = $ENV{STOMP_HOST} || "localhost"; $Option{port} = $ENV{STOMP_PORT} || 61613; $Option{destination} = $ENV{STOMP_DESTINATION} || "/topic/event"; $Option{count} = $ENV{STOMP_COUNT} || 10000; $Conn = Net::STOMP::Client->new( host => $Option{host}, port => $Option{port}, ); $Conn->connect( login => $Option{user}, passcode => $Option{password}, ); printf("connected to %s:%d\n", $Conn->peer()->addr(), $Conn->peer()->port()); $Start = time(); foreach (1 .. $Option{count}) { $Conn->send( destination => $Option{destination}, persistent => "false", body => "Hello world from Perl", ); } $Conn->send( destination => $Option{destination}, persistent => "false", body => "SHUTDOWN", ); printf("sent %d messages in %.3f seconds\n", $Option{count}+1, time()-$Start); $Conn->disconnect();