Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bbrowning's full-sized avatar

Ben Browning bbrowning

  • Red Hat
  • Ashburn, VA
View GitHub Profile
class MessagingStatsService
def start
Thread.new do
until @done
queues.each do |queue|
counter = org.hornetq.api.core.management.MessageCounterInfo.from_json(queue.list_message_counter)
puts "Queue #{queue.name} count: #{counter.count} countDelta: #{counter.count_delta} depth: #{counter.depth} depth_delta: #{counter.depth_delta}"
end
end
require 'erb'
NUM_THREADS = 400
puts "Thread with string"
threads = NUM_THREADS.times.map {
Thread.new do
'1'
end
}
@bbrowning
bbrowning / output
Last active December 12, 2015 07:59
bbrowning@bbrowning-mbp:~$ curl -I http://localhost:8080/posts/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: foobar=k5wDvCA2jZvAlwqb2HgFMdsX; Domain=foobar.com; Expires=Fri, 08-Feb-2013 18:17:44 GMT; Path=/baz; Secure; HttpOnly
X-UA-Compatible: IE=Edge
ETag: "903b327bb0b526d7d9b6b4d8344fc56f"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 9cac85c7ee32c524896767ff8ce730ca
X-Runtime: 0.796000
Content-Type: text/html;charset=utf-8
@bbrowning
bbrowning / proxy.diff
Created February 4, 2013 17:14
Maven RubyGems proxy fix
diff --git a/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java b/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
index a9a46b5..0e54554 100644
--- a/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
+++ b/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
@@ -31,7 +31,7 @@ public class Controller {
private static final String SHA1 = ".sha1";
- private static final String RUBYGEMS_URL = "http://rubygems.org/gems";
+ private static final String RUBYGEMS_URL = "https://rubygems.org/gems";
@bbrowning
bbrowning / highspeedpublish.rb
Created January 8, 2013 19:59
Example of publishing messages at a high speed with TorqueBox
queue = TorqueBox::Messaging::Queue.new('/queue/foo')
options = { :startup_timeout => 500, :persistent => false, :tx => false }
normalized_options = queue.normalize_options(options)
queue.wait_for_destination(options[:startup_timeout]) do
queue.with_session(options) do |session|
# loop here and publish each message
5.times { session.publish(queue, Time.now.to_s, normalized_options) }
end
end
TORQUEBOX_SERVER=standalone.xml
TORQUEBOX_HOME=/opt/torquebox
RUN=yes
diff --git a/gems/jruby-openssl/Rakefile b/gems/jruby-openssl/Rakefile
index c854e2a..c7cddfc 100644
--- a/gems/jruby-openssl/Rakefile
+++ b/gems/jruby-openssl/Rakefile
@@ -38,7 +38,7 @@ task :java_compile do
end
sh "javac @pkg/compile_options @pkg/compile_classpath @pkg/compile_sourcefiles"
- sh "jar cf ../../lib/ruby/shared/jopenssl.jar -C pkg/classes/ ."
+ sh "jar cf lib/shared/jopenssl.jar -C pkg/classes/ ."
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ time jruby -S bundle install
...
Your bundle is complete! It was installed into /Users/bbrowning/Downloads/torquebox-current/jruby/lib/ruby/gems/1.8
real 0m51.642s
user 0m51.210s
sys 0m3.595s
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ rm Gemfile.lock
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ time jruby -X-C -S bundle install
...
@bbrowning
bbrowning / Mongo Runtime Leak
Created December 17, 2012 20:46
Script to reproduce mongo ruby driver's runtime leak
bbrowning@bbrowning-mbp:~/tmp$ jruby mongo_leak.rb 2
Leaked 2 Ruby runtimes in RubyBSONCallback
Uncomment lines 15-16 of mongo_leak.rb and run again
bbrowning@bbrowning-mbp:~/tmp$ jruby mongo_leak.rb 2
Leaked 0 Ruby runtimes in RubyBSONCallback
@bbrowning
bbrowning / TorqueBox on Heroku.md
Last active December 9, 2015 16:19
TorqueBox on Heroku

With Heroku's JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

This example uses TorqueBox 3.0.2, but the instructions may work with other TorqueBox versions.

Steps Required

  1. Create a JRuby application on Heroku, or convert an existing application to JRuby. Make sure your application works on JRuby on Heroku before throwing TorqueBox into the mix.
  2. Add th