class LogStash::Outputs::Jms
Write events to a Jms
Broker. Supports both Jms
Queues and Topics.
For more information about Jms
, see <docs.oracle.com/javaee/6/tutorial/doc/bncdq.html> For more information about the Ruby Gem used, see <github.com/reidmorrison/jruby-jms> Here is a config example :
jms { include_header => false include_properties => false include_body => true use_jms_timestamp => false queue_name => "myqueue" yaml_file => "~/jms.yml" yaml_section => "mybroker" }
Public Instance Methods
close()
click to toggle source
# File lib/logstash/outputs/jms.rb, line 132 def close @producer.close() @session.close() @connection.close() end
receive(event)
click to toggle source
# File lib/logstash/outputs/jms.rb, line 121 def receive(event) begin @producer.send(@session.message(event.to_json)) rescue => e @logger.warn("Failed to send event to JMS", :event => event, :exception => e, :backtrace => e.backtrace) end end
register()
click to toggle source
:yaml_file, :factory and :jndi_name are mutually exclusive, both cannot be supplied at the same time. The priority order is :yaml_file, then :jndi_name, then :factory
JMS Provider specific properties can be set if the JMS Factory itself has setters for those properties.
For some known examples, see: [Example jms.yml](github.com/reidmorrison/jruby-jms/blob/master/examples/jms.yml)
# File lib/logstash/outputs/jms.rb, line 73 def register require "jms" @connection = nil if @yaml_file @jms_config = YAML.load_file(@yaml_file)[@yaml_section] elsif @jndi_name @jms_config = { :require_jars => @require_jars, :jndi_name => @jndi_name, :jndi_context => @jndi_context} elsif @factory @jms_config = { :require_jars => @require_jars, :factory => @factory, :username => @username, :password => @password, :broker_url => @broker_url, :url => @broker_url # "broker_url" is named "url" with Oracle AQ } end @logger.debug("JMS Config being used", :context => @jms_config) begin # The jruby-jms adapter dynamically loads the Java classes that it extends, and may fail @connection = JMS::Connection.new(@jms_config) rescue NameError => ne if @require_jars && !@require_jars.empty? logger.warn('The `require_jars` directive was provided, but may not correctly map to a JNS provider', :require_jars => @require_jars) end logger.error('Failed to load JMS Connection, likely because a JMS Provider is not on the Logstash classpath '+ 'or correctly specified by the plugin\'s `require_jars` directive', :exception => ne.message, :backtrace => ne.backtrace) fail(LogStash::PluginLoadingError, 'JMS Input failed to load, likely because a JMS provider was not available') end @session = @connection.create_session() # Cache the producer since we should keep reusing this one. destination_key = @pub_sub ? :topic_name : :queue_name @producer = @session.create_producer(@session.create_destination(destination_key => @destination)) # If a delivery mode has been specified, inform the producer @producer.delivery_mode_sym = @delivery_mode.to_sym unless @delivery_mode.nil? end