{"id":1882,"date":"2010-12-18T21:12:06","date_gmt":"2010-12-18T20:12:06","guid":{"rendered":"http:\/\/www.devco.net\/?p=1882"},"modified":"2010-12-18T21:12:06","modified_gmt":"2010-12-18T20:12:06","slug":"custom_stomp_irb_shell","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2010\/12\/18\/custom_stomp_irb_shell.php","title":{"rendered":"Custom STOMP IRB shell"},"content":{"rendered":"

Some time ago I wrote a little STOMP client<\/a> – 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.<\/p>\n

So today I wrote a custom IRB, you can see it below:<\/p>\n

<\/p>\n

\r\n$ stomp-irb -s stomp --port 6163\r\nInteractive Ruby shell for STOMP\r\n\r\nType 'help' for usage instructions\r\n\r\n>> subscribe :topic, \"foo.bar\"\r\nCurrent Subscriptions:\r\n    \/topic\/foo.bar\r\n\r\n=> nil\r\n>> topic \"foo.bar\", \"hello\"\r\n=> nil\r\n<> hello\r\n\r\n>> recv_callback {|f| puts \"Received: #{f.body} from #{f.headers[\"destination\"]}\"}\r\n>> topic \"foo.bar\", \"hello\"\r\n=> nil\r\n<> hello\r\nReceived: hello from \/topic\/foo.bar\r\n\r\n>> 10.times {|i| topic \"foo.bar\", i}\r\n=> 10\r\n<> 0\r\n<> 1\r\n<> 2\r\n<> 3\r\n<> 4\r\n<> 5\r\n<> 6\r\n<> 7\r\n<> 8\r\n<> 9\r\n\r\n>> verbose\r\n=> true\r\n>> topic \"foo.bar\", \"hello world\"\r\n=> nil\r\n<<20:02:07:\/topic\/foo.bar>> hello world\r\n<\/pre>\n

<\/code><\/p>\n

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.<\/p>\n

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, […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[1],"tags":[121,13,93],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1882"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=1882"}],"version-history":[{"count":3,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1882\/revisions"}],"predecessor-version":[{"id":1885,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1882\/revisions\/1885"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=1882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=1882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=1882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}

The code is hosted on GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"