reidmorrison / jruby-jms

Complete JRuby API into Java Messaging Specification (JMS)
Apache License 2.0
47 stars 21 forks source link

require jars implementation #3

Closed tohvu closed 13 years ago

tohvu commented 13 years ago

Hi, I have a problem with the changes since 0.90. to the required jars functionality. If I don't include required jars in the config hash I get this: undefined method `producer' for #<Java::OrgApacheActivemq::ActiveMQSession:0x59444b1d>

The required classes are available in the classpath.

In 0.90.0 if I had the classes in classpath the require's for the jar's weren't needed.

tohvu commented 13 years ago

Oh right, my implementation that's causing the error if this helps:

class JMSClient

  def initialize(factory, broker_url)
    @config = {
        :factory => factory,
        :broker_url => broker_url
    }
    if ENV['RACK_ENV'] == "development"
      @config[:require_jars] = ["~/.m2/repository/org/apache/activemq/activemq-all/5.4.1/activemq-all-5.4.1.jar"]
    end
  end

  def send(queue_name, data)
    JMS::Connection.session(@config) do |session|
      session.producer(:queue_name => queue_name) do |producer|
        message = session.message(data)
        message.jms_delivery_mode = :persistent
        producer.send(message)
      end
    end
  end
end
tohvu commented 13 years ago

https://github.com/tohvu/jruby-jms/tree/connection_fix link to my fix Apparently I closed the issue unintentionally. I am a total github newb ;)

reidmorrison commented 13 years ago

Thank you for the example. Looks like the issue is not straight forward, I will look into it tonight after work.

reidmorrison commented 13 years ago

Thank you for identifying and reporting this issue. Turned out to be quite simple, but took a while to hunt down.

Fixed in Gem 0.10.2

Closing for now. Just post a new comment to this issue if it does not work as expected.