Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not omit username and password if JNDI lookup was chosen #11

Open
aleskovets opened this issue Aug 23, 2016 · 2 comments
Open

Do not omit username and password if JNDI lookup was chosen #11

aleskovets opened this issue Aug 23, 2016 · 2 comments

Comments

@aleskovets
Copy link

Hi!

Is there any specific reason why username and password is not passed to jms_config in jndi lookup was chosen? I am trying to integrate this plugin with the Tibco EMS and it seems like Tibco's Connection Manager expects username/password passed for Connection creation even if java.naming.security.principal and java.naming.security.credentials were presented during the lookup.

If jms_config block is reconfigured like below everything works just fine:

elsif @jndi_name
      @jms_config = {
        :require_jars => @require_jars,
        :jndi_name => @jndi_name,
        :jndi_context => @jndi_context,
        :username => @username, # tibco ems expects username and password on Connection creation
        :password => @password
}

Is it possible to pass username and password to jms_config even if jndi lookup was chosen?

@gjelu
Copy link

gjelu commented Dec 29, 2016

A Tibco EMS client indeed needs a username and password for JNDI lookup unless anonymous logins are allowed (see EMS documentation).

Theoretically the jndi username/password doesn't need to be the same as the JMS client username/password (but in practice it is in most cases). Personally I believe that 2 new config parameters jndi_username and jndi_password would be more correct. That would also reflect a yaml configuration.

A workaround can be achieved by using a yaml for the connection parameters and use the logstash config only for the configuration of your destination.

Example

# File 1: The logstash configuration, pub_sub should be set to true when subscribing on a topic
input {
   jms {
      include_header => true
      include_properties => true
      include_body => true
      use_jms_timestamp => true
      timeout => -1
      destination => "q.logstash.command"
      pub_sub => false
      yaml_file => "/opt/app/logstash/config/ems.yml"
      yaml_section => "ems"
   }
}
output { ... }

# File 2: /opt/app/logstash/config/ems.yml 
ems:
  :username: admin
  :password: admin
  :jndi_name: ConnectionFactory
  :jndi_context:
    java.naming.factory.initial: com.tibco.tibjms.naming.TibjmsInitialContextFactory
    java.naming.provider.url: tcp://localhost:7222
    java.naming.security.principal: admin
    java.naming.security.credentials: admin
  :require_jars:
    - /opt/app/logstash/config/libs-ems/jms-2.0.jar
    - /opt/app/logstash/config/libs-ems/tibjms.jar
    - /opt/app/logstash/config/libs-ems/tibcrypt.jar

@rabinzhere
Copy link

Hi,

I have used the same configuration but getting following error. Could you please help?

][main][78b0cd62e58d9956aee9af1f0dad237438a87cead6d53972bd702a7515f4af7e] JMS Consumer Died {:exception=>"Java::JavaxJms::JMSException", :exception_message=>"Failed to connect to the server at tcp://innolx133105:7222", :backtrace=>["com.tibco.tibjms.TibjmsxLinkTcp.createSocket(com/tibco/tibjms/TibjmsxLinkTcp.java:823)", "com.tibco.tibjms.TibjmsxLinkTcp.connect(com/tibco/tibjms/TibjmsxLinkTcp.java:914)", "com.tibco.tibjms.TibjmsConnection.create(com/tibco/tibjms/TibjmsConnection.java:1359)", "com.tibco.tibjms.TibjmsConnection.(com/tibco/tibjms/TibjmsConnection.java:4333)", "com.tibco.tibjms.TibjmsxCFImpl.createImpl(com/tibco/tibjms/TibjmsxCFImpl.java:209)", "com.tibco.tibjms.TibjmsxCFImpl.createConnection(com/tibco/tibjms/TibjmsxCFImpl.java:253)", "com.tibco.tibjms.TibjmsConnectionFactory.createConnection(com/tibco/tibjms/TibjmsConnectionFactory.java:61)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:471)", "org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:329)", "C_3a.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.vendor.bundle.jruby.$2_dot_5_dot_0.gems.jruby_minus_jms_minus_1_dot_3_dot_0_minus_java.lib.jms.connection.initialize(C:/Users/erabibh/Downloads/logstash-7.11.0/vendor/bundle/jruby/2.5.0/gems/jruby-jms-1.3.0-java/lib/jms/connection.rb:202)", "C_3a.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_input_minus_jms_minus_3_dot_1_dot_2_minus_java.lib.logstash.inputs.jms.run(C:/Users/erabibh/Downloads/logstash-7.11.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jms-3.1.2-java/lib/logstash/inputs/jms.rb:225)", "C_3a.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_input_minus_jms_minus_3_dot_1_dot_2_minus_java.lib.logstash.inputs.jms.RUBY$method$run$0$VARARGS(C_3a/Users/erabibh/Downloads/logstash_minus_7_dot_11_dot_0/vendor/bundle/jruby/$2_dot_5_dot_0/gems/logstash_minus_input_minus_jms_minus_3_dot_1_dot_2_minus_java/lib/logstash/inputs/C:/Users/erabibh/Downloads/logstash-7.11.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jms-3.1.2-java/lib/logstash/inputs/jms.rb)", "C_3a_.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.logstash_minus_core.lib.logstash.java_pipeline.inputworker(C:/Users/erabibh/Downloads/logstash-7.11.0/logstash-core/lib/logstash/java_pipeline.rb:405)", "C_3a_.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.logstash_minus_core.lib.logstash.java_pipeline.RUBY$method$inputworker$0$VARARGS(C_3a_/Users/erabibh/Downloads/logstash_minus_7_dot_11_dot_0/logstash_minus_core/lib/logstash/C:/Users/erabibh/Downloads/logstash-7.11.0/logstash-core/lib/logstash/java_pipeline.rb)", "C_3a_.Users.erabibh.Downloads.logstash_minus_7_dot_11_dot_0.logstash_minus_core.lib.logstash.java_pipeline.start_input(C:/Users/erabibh/Downloads/logstash-7.11.0/logstash-core/lib/logstash/java_pipeline.rb:396)", "org.jruby.RubyProc.call(org/jruby/RubyProc.java:318)", "java.lang.Thread.run(java/lang/Thread.java:748)"]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants