create_destination method in jruby-jms-1.3.0-java gem(latest version) with jRuby 9.4.5.0 still have java_kind_of?(JMS::Destination) which is giving me error:
"undefined method `java_kind_of?' for #<Java::OrgApacheActivemqCommand::ActiveMQQueue:0x70d2433a>", "Did you mean? java_send (NoMethodError)"]
I am calling create_destination, but it gives this error for consumer only.
/usr/jruby-9.4.5.0/lib/ruby/gems/shared/gems/jruby-jms-1.3.0-java/lib/jms/session.rb:180:in `create_destination'
/usr/jruby-9.4.5.0/lib/ruby/gems/shared/gems/jruby-jms-1.3.0-java/lib/jms/session.rb:350:in `consumer'
jms_consume method:
def jms_consume _queue = self.receive_queue, _selector = ''
consumed = nil
JMS::Connection.session(@jms_config) { |session|
session.queue(_queue){ |q|
session.consumer(:destination => q, :selector=>_selector) { |consumer|
message = consumer.get(:timeout => 5000)
log.debug "Consumed message #{message.data}" unless message.nil?
consumed = message != nil ? message.data : nil
}
}
}
consumed
end
As per this issue, java_kind_of has been removed and have to be replaced with kind_of. It works if I change it, but have to change it with every installation of tool.
How do I proceed ?
Apparently the last release of the jruby-jms gem was in January 2019, and the GitHub repository was archived in January 2020. It doesn't look like this project is maintained anymore.
If you still want to continue using this gem, one option could be to fork and fix it yourself. The actual fix in this case is simple: just search the gem code for any uses of
java_kind_of?and replace them withkind_of?.If you also release the fixed gem to the public, instead of just maintaining a private fork, this also allows others to benefit from your improvements and maintenance, and perhaps to contribute their own improvements back.
Alternatively, if you really don't want to fork the gem, another option is to monkey-patch the removed
java_kind_of?method back, as suggested by enebo on the issue thread you linked in your question:You will, of course, need to apply this patch before calling any code that uses the
java_kind_of?method. A safe place to do that is either before requiring thejmsgem or, if you're using e.g. Bundler to load the gem, in your application startup code before loading Bundler. (In a Rails app, putting this code in an initializer would likely also work, at least unless you somehow use thejmsgem in your app startup code.)Of course, a compatibility patch like this is really only a temporary fix. The real problem is that you're using an unmaintained gem dependency which is likely to accumulate more and more "bit rot" over time. Unless someone else just happens to step up to fork the gem and take over its maintenance, eventually you'll likely have to decide between forking and maintaining it yourself or giving up on it and switching to some alternative solution.