Installing RabbitMQ + Stomp in Ubuntu/Mac
Posted by jcastaneyra in OpenSource on May 30, 2010

In the project I’m working now it was needed to have RabbitMQ running with Stomp as a message queue for Orbited, we know that Orbited comes with MorbidQ, but in our system we already had running RabbitMQ and used by other processes, so, two queue systems at the same time were not needed.
But, searching for Stomp over RabbitMQ info or some kind of tutorial was difficult and painful, a friend of mine would say “a real pain in the ass”, there was info but not too clear. For that reason here is another note to myself, just in case.
- RabbitMQ 1.6.0 installed, here there are some steps to install it.
- Mercurial is needed to download Stomp code
- Download Stomp code
hg clone -r rabbitmq_v1_6_0 http://hg.rabbitmq.com/rabbitmq-stomp
cd rabbitmq-stomp make RABBIT_SERVER_INCLUDE_DIR=/usr/lib/erlang/lib/rabbitmq_server-1.6.0/include
sudo mkdir -p /usr/lib/erlang/lib/rabbitmq-stomp sudo cp -R * /usr/lib/erlang/lib/rabbitmq-stomp
sudo vim /etc/rabbitmq/rabbitmq.conf
#Add the lines below
NODENAME=rabbit
NODE_IP_ADDRESS=0.0.0.0
NODE_PORT=5672
LOG_BASE=/var/log/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia
SERVER_START_ARGS='
-pa /usr/lib/erlang/lib/rabbitmq-stomp/ebin
-rabbit
stomp_listeners [{"0.0.0.0",61613}]
extra_startup_steps [{"STOMP-listeners",rabbit_stomp,kickstart,[]}]'
And that’s it, if you start RabbitMQ will see how STOMP-Listeners are starting (In Linux you maybe will need to stop RabbitMQ with the following command sudo /etc/init.d/rabbitmq-server stop before running the next step, in my Mac I use this command to start RabbitMQ sudo /usr/local/lib/erlang/lib/rabbitmq_server-1.6.0/sbin/rabbitmq-server)
deploy@localhost:~$ sudo rabbitmq-server RabbitMQ 1.6.0 (AMQP 8-0) Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. Licensed under the MPL. See http://www.rabbitmq.com/ node : rabbit@localhost log : /var/log/rabbitmq/rabbit.log sasl log : /var/log/rabbitmq/rabbit-sasl.log database dir: /var/lib/rabbitmq/mnesia/rabbit starting database ...done starting core processes ...done starting recovery ...done starting persister ...done starting guid generator ...done starting builtin applications ...done starting TCP listeners ...done starting STOMP-listeners ...done broker running

En el proyecto en el que estoy trabajando era necesario tener corriendo RabbitMQ con Stomp para poder hacer conexiones con Orbited, Orbited ya incluye MorbidQ, pero en este caso ya teníamos corriendo RabbitMQ para otros procesos y no era necesario tener un segundo sistema de queues.
Sorprendentemente, encontrar información de cómo agregar Stomp a RabbitMQ resultó algo doloroso, si había información pero como que no indicaba bien que pasos seguir. Entonces como parte de mis notas personales estoy agregando esta receta por si se llega a ofrecer de nueva cuenta.
- Tener instalado RabbitMQ 1.6.0, aquí hay unos pasos para instalarlo.
- Tener instalado Mercurial para bajar el código de Stomp
- Bajar el código de Stomp
hg clone -r rabbitmq_v1_6_0 http://hg.rabbitmq.com/rabbitmq-stomp
cd rabbitmq-stomp make RABBIT_SERVER_INCLUDE_DIR=/usr/lib/erlang/lib/rabbitmq_server-1.6.0/include
sudo mkdir -p /usr/lib/erlang/lib/rabbitmq-stomp sudo cp -R * /usr/lib/erlang/lib/rabbitmq-stomp
sudo vim /etc/rabbitmq/rabbitmq.conf
#Add the lines below
NODENAME=rabbit
NODE_IP_ADDRESS=0.0.0.0
NODE_PORT=5672
LOG_BASE=/var/log/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia
SERVER_START_ARGS='
-pa /usr/lib/erlang/lib/rabbitmq-stomp/ebin
-rabbit
stomp_listeners [{"0.0.0.0",61613}]
extra_startup_steps [{"STOMP-listeners",rabbit_stomp,kickstart,[]}]'
Listo, si intentan arrancar RabbitMQ se verá que dice que está levantando los STOMP-Listeners (En Linux talvez necesiten terminar el proceso con sudo /etc/init.d/rabbitmq-server stop antes de correr lo siguiente, y en Mac para levantar el servidor yo ejecuto sudo /usr/local/lib/erlang/lib/rabbitmq_server-1.6.0/sbin/rabbitmq-server)
deploy@localhost:~$ sudo rabbitmq-server RabbitMQ 1.6.0 (AMQP 8-0) Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. Licensed under the MPL. See http://www.rabbitmq.com/ node : rabbit@localhost log : /var/log/rabbitmq/rabbit.log sasl log : /var/log/rabbitmq/rabbit-sasl.log database dir: /var/lib/rabbitmq/mnesia/rabbit starting database ...done starting core processes ...done starting recovery ...done starting persister ...done starting guid generator ...done starting builtin applications ...done starting TCP listeners ...done starting STOMP-listeners ...done broker running
Bundler gem and Daemons error (The default Gemfile was not found)
Posted by jcastaneyra in Ruby, scripting on February 12, 2010
Some days ago we deployed an application with rails, in this application we are using some daemons (with daemons gem) to take care about some business processes, and recently to have more control with all gems used by our application we started to use bundler.
Almost all was done, so, at the moment to start the daemons, we get the following error:
/usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:122:in `default_gemfile': The default Gemfile was not found (Bundler::GemfileNotFound) from /usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:64:in `setup'
So, looking for this error in google we didn’t get anything, and looking into the bundler gem code the solution to this problems was:
ENV['BUNDLE_GEMFILE'] ||= File.join(Dir.pwd, 'Gemfile')
The complete daemon code here:
Hace algunos días hicimos el deployment de una aplicación con rails, con esta aplicación corremos algunos demonios (con la gema daemons) que se hacen cargo de algunas operaciones de negocio, y recientemente para tener más control de las gemas que utilizamos empezamos a usar bundler.
Ya se tenía todo listo, al momento de correr los demonios nos encontramos con el siguiente error:
/usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:122:in `default_gemfile': The default Gemfile was not found (Bundler::GemfileNotFound) from /usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:64:in `setup'
Cabe mencionar que buscando en google no se encontró nada de como resolver el problema, así que indagando un poco en el código de bundler, llegamos a la siguiente solución, que fue agregar la siguiente línea al código que levanta nuestro demonio.
ENV['BUNDLE_GEMFILE'] ||= File.join(Dir.pwd, 'Gemfile')
El código completo del demonio es el siguiente:
Se busca desarrollador rails
Posted by jcastaneyra in Uncategorized on January 21, 2010
Nota: Deja un comentario aquí si estás interesado o bien manda un correo con tu CV a jcastaneyra@gmail.com.
Table names case insensitive for MySQL Linux
Posted by jcastaneyra in Linux, OpenSource on January 7, 2010
Hola a todos, feliz año 2010, que tal se pasaron estas fechas? descansaron bastante? Pues yo más o menos, unos ratos descansaba y otros trabajaba, y para variar me encontré con esto en el trabajo.
Resulta que estaba montando un servidor de Weblogic y MySQL en Linux, para instalar una aplicación que originalmente estaba con Weblogic y Oracle, y resulta que al cargar las tablas de esta aplicación en MySQL empecé a encontrarme problemas con los nombres de las tablas (entre otras cosas, como los tipos de datos entre Oracle y MySQL), yo no sabía que MySQL por default en Linux es case sensitive, por lo que me di a la tarea de investigar y buscar como deshabilitar esta función.
Es necesario editar el archivo my.cnf que se puede encontrar en /etc o bien en /etc/mysql, e inmediatamente después de la sección [mysqld], agregar lo siguiente:
lower_case_table_names=1
Guardamos el archivo y reiniciamos MySQL, con esto al momento de crear nuevas tablas estas se harán en minúsculas, y ya no tendremos problemas de si son mayúsculas o minúsculas.
Como crear un archivo zip con ruby
Posted by jcastaneyra in Howto/tutorial, Ruby on November 16, 2009
Hace unos días me encontré con el problema de generar archivos Zip que contuvieran archivos de un curso de SCORM, ¿Cómo hacerlo?, lo primero que me vino a la mente fue Ruby!!!
La gema que me sirvió para esto fue rubyzip, y con el siguiente fragmento de código se realizaron los archivos zip:
Espero que les sirva como a mi.
Links:
http://ruby-doc.org/core/classes/Dir.html
http://ruby-doc.org/core/classes/FileUtils.html
http://rubyzip.sourceforge.net/
Etiquetando código en git/Tagging code in git
Posted by jcastaneyra in Lenguajes, Ocio on November 5, 2009
Etiquetando código en git (English)
Resulta que al estar trabajando con nuestro código queremos marcar o etiquetar nuestro código en cierto momento de tiempo, algo así como versionar nuestro código.
A decir verdad no soy un experto en git, pero esto es lo que me ha funcionado. Primero que nada tendríamos que etiquetar nuestro código (ponerle una marca), para esto usamos el comando git tag:
git tag -a -m "My old and ugly style" old_style
Para ver nuestros tags locales tenemos que ejecutar
git tag -lPero como le agregué una descripción a mi tag ejecuto lo siguiente para poder ver el tag junto con su descripción
git tag -l -n1
Con esto tenemos agregado el tag localmente, pero como yo trabajo con un repositorio remoto, para subir mi tag tengo que hacer
git push origin --tagsYa tengo una etiqueta en mi código, ahora supongamos que pasan dos semanas y que quiero ver algo en mi viejo y feo estilo, sólo tendría que hacer lo siguiente:
git checkout -f -b mybranch old_style
Así tendría un nuevo branch con mi código que tiene la etiqueta de old_style.
Links:
http://ariejan.net/2009/09/05/git-tag-mini-cheat-sheet-revisited/?doing_wp_cron
http://polywww.in2p3.fr/~gaycken/Calice/Software/my_git_workflow.html
When we are working with our code in some time of the project we want to mark or tag the code in order to have control until that time of the project and code, something like versioning.
I’m not a git expert, but this worked for me. First of all, we need to tag our code, use this command:
git tag -a -m "My old and ugly style" old_style
In order to see all local tags
git tag -lSince I added a description to my tag it’s needed to execute the following to see the description
git tag -l -n1
Until now we have this tag added locally, but if we work with a remote repository we are going to push the tag
git push origin --tagsI already have this tag in my code, now suppose that some weeks have been passed and you want to see something in your old and ugly style, you would need to do:
git checkout -f -b mybranch old_style
With this command you would have a new branch with the code tagged with old_style.
Links:
http://ariejan.net/2009/09/05/git-tag-mini-cheat-sheet-revisited/?doing_wp_cron
http://polywww.in2p3.fr/~gaycken/Calice/Software/my_git_workflow.html
Recent Comments