reidmorrison / jruby-jms

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

Fixes for Websphere MQ v7 #10

Closed apaolini closed 11 years ago

apaolini commented 12 years ago

I was playing with jruby-jms and IBM Websphere MQ (WMQ) and found that apparently WMQ v7 implements a lot of methods that clash with the one defined in the gem.

So, like you did with the #consume method in lib/jms/session.rb, I had to work around this and force the execution of the "right" method. I've put the workarounds in an independent file, lib/jms/mq_workaround.rb.

In my branch you'll find also a couple of small changes to the tests (cfr test/message_test.rb) that I did to please WMQ, trying not to change the logic of the tests and to respect behavior of the other QMs. Specifically:

I've tested my changes with jruby 1.6.5 and:

... and everything seems OK, but I'm a newbie with jms, ruby and github and I hope everything is fine.

karsaroth commented 9 years ago

@apaolini @reidmorrison Is it necessary to do anything special for these workarounds to have an effect? I've run into problems with WMQ while trying to use a jms input for logstash, and I came across this pull request while investigating the issue. In the version I'm using these workarounds are included, yet I'm still getting errors around the consume function when trying to pull messages from a queue.

I thought it'd be best to check here before raising an issue.

For reference I'm using jruby-jms 1.1.0 via this logstash jms input: https://github.com/elasticsearch/logstash-contrib/pull/26 and I've tried on both WMQ 7.0.1.12 and 7.5

The code from the logstash input that's causing the problem is:

JMS::Connection.session(@jms_config) do |session|
    while(true)
        if (@pub_sub)
            session.consume(:topic_name => @descriptor, :timeout=>@timeout, :selector => @selector) do |message|
                queue_event message, output_queue
            end
        else
            session.consume(:queue_name => @descriptor, :timeout=>@timeout, :selector => @selector) do |message|
                queue_event message, output_queue
            end
        end
        sleep @interval
    end
end
apaolini commented 9 years ago

@karsaroth there was nothing "special" for the workaround activation, but its code is 2 years old and must me checked against jruby 1.7 (with the 1.9 syntax). I'll try to have a look tonight after work.

apaolini commented 9 years ago

@karsaroth maybe this https://github.com/reidmorrison/jruby-jms/pull/18 fixes your issue?

karsaroth commented 9 years ago

@apaolini It does, thank you!