diff --git a/hermann.gemspec b/hermann.gemspec index b8c97ad..492ee30 100644 --- a/hermann.gemspec +++ b/hermann.gemspec @@ -24,14 +24,13 @@ Gem::Specification.new do |s| s.rubygems_version = '2.2.2' s.specification_version = 3 if s.respond_to?(:specification_version) - s.add_dependency 'concurrent-ruby', '~> 0.7.0' - s.add_dependency 'thread_safe', '~> 0.3.4' - if RUBY_PLATFORM == "java" # IMPORTANT: make sure that jar-dependencies is only a development # dependency of your gem. if it is a runtime dependencies the require_jars # file will be overwritten during installation. s.add_dependency 'jar-dependencies', '~>0.1.9' + s.add_dependency 'concurrent-ruby', '~> 0.7.0' + s.add_dependency 'thread_safe', '~> 0.3.4' s.requirements << "jar org.apache.kafka:kafka_2.10, ~>0.8.1.1, ['junit:junit']" # use log4j-1.2.16+ to as 1.2.15 declares deps which are not in maven central and causes the dep resolution to fail s.requirements << "jar log4j:log4j, ~>1.2.16" diff --git a/lib/hermann/provider/java_producer.rb b/lib/hermann/provider/java_producer.rb index de5c9d3..148aee0 100644 --- a/lib/hermann/provider/java_producer.rb +++ b/lib/hermann/provider/java_producer.rb @@ -1,8 +1,11 @@ require 'hermann' -require 'concurrent' require 'json' require 'hermann/errors' +if Hermann.jruby? + require 'concurrent' +end + module Hermann module Provider # This class simulates the kafka producer class within a java environment. diff --git a/spec/integration/producer_spec.rb b/spec/integration/producer_spec.rb index 20d7067..93da1d1 100644 --- a/spec/integration/producer_spec.rb +++ b/spec/integration/producer_spec.rb @@ -3,7 +3,10 @@ require 'spec_helper' require 'hermann/producer' require 'hermann/consumer' require 'hermann/discovery/zookeeper' -require 'concurrent' + +if Hermann.jruby? + require 'concurrent' +end require 'protobuf' require_relative '../fixtures/testevent.pb' @@ -14,7 +17,7 @@ describe 'producer' do let(:timeout) { 10 } let(:message) { 'msg' } let(:consumer) do - Hermann::Consumer.new(topic, "rspec-group", zookeepers) + Hermann::Consumer.new(topic, {:group_id => "rspec-group", :zookeepers => zookeepers}) end let(:consumer_promise) do Concurrent::Promise.execute do