Some time ago I wrote a little STOMP client – you couldn’t do a whole lot with it since it just sent and printed what it received. I always wanted something better that I can code on the fly and have since learned how to code custom IRBs.
So today I wrote a custom IRB, you can see it below:
$ stomp-irb -s stomp --port 6163 Interactive Ruby shell for STOMP Type 'help' for usage instructions >> subscribe :topic, "foo.bar" Current Subscriptions: /topic/foo.bar => nil >> topic "foo.bar", "hello" => nil <<stomp>> hello >> recv_callback {|f| puts "Received: #{f.body} from #{f.headers["destination"]}"} >> topic "foo.bar", "hello" => nil <<stomp>> hello Received: hello from /topic/foo.bar >> 10.times {|i| topic "foo.bar", i} => 10 <<stomp>> 0 <<stomp>> 1 <<stomp>> 2 <<stomp>> 3 <<stomp>> 4 <<stomp>> 5 <<stomp>> 6 <<stomp>> 7 <<stomp>> 8 <<stomp>> 9 >> verbose => true >> topic "foo.bar", "hello world" => nil <<20:02:07:/topic/foo.bar>> hello world |
As you can see you can set custom callbacks that run any Ruby code and execute Ruby code to create messages, overall its much more useful.
The code is hosted on GitHub.