Module: HornetQ

Defined in:
lib/hornetq/common/logging.rb,
lib/hornetq.rb,
lib/hornetq/uri.rb,
lib/hornetq/client.rb,
lib/hornetq/server.rb,
lib/hornetq/client/connection.rb,
lib/hornetq/common/log_delegate.rb

Overview

Add HornetQ logging capabilities

Defined Under Namespace

Modules: Client, Server Classes: LogDelegate, LogDelegateFactory, URI

Constant Summary collapse

NETTY_CONNECTOR_CLASS_NAME =

Netty Class name

'org.hornetq.core.remoting.impl.netty.NettyConnectorFactory'
NETTY_ACCEPTOR_CLASS_NAME =
'org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory'
INVM_CONNECTOR_CLASS_NAME =
'org.hornetq.core.remoting.impl.invm.InVMConnectorFactory'
INVM_ACCEPTOR_CLASS_NAME =
'org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory'
DEFAULT_NETTY_PORT =
java.lang.Integer.new(5445)
DEFAULT_DATA_DIRECTORY =
'./data'

Class Method Summary collapse

Class Method Details

.as_simple_string(str) ⇒ Object

Convert string into a HornetQ SimpleString



29
30
31
# File 'lib/hornetq.rb', line 29

def self.as_simple_string(str)
 str.is_a?(Java::org.hornetq.api.core::SimpleString) ? str : Java::org.hornetq.api.core::SimpleString.new(str.to_s) 
end

.loggerObject

Returns the logger being used by both HornetQ and jruby-hornetq



4
5
6
# File 'lib/hornetq/common/logging.rb', line 4

def self.logger
  @logger ||= (self.rails_logger || self.default_logger)
end

.logger=(logger) ⇒ Object

Replace the logger for both HornetQ and jruby-hornetq TODO Directly support Log4J as logger since HornetQ has direct support for Log4J



10
11
12
13
14
15
16
17
18
19
# File 'lib/hornetq/common/logging.rb', line 10

def self.logger=(logger)
  @logger = logger
  # Also replace the HornetQ logger
  if @logger
    Java::org.hornetq.core.logging::Logger.setDelegateFactory(HornetQ::LogDelegateFactory.new)
  else
    Java::org.hornetq.core.logging::Logger.reset      
  end
  # TODO org.hornetq.core.logging.Logger.setDelegateFactory(org.hornetq.integration.logging.Log4jLogDelegateFactory.new)
end

.netty_port(port) ⇒ Object



23
24
25
26
# File 'lib/hornetq.rb', line 23

def self.netty_port(port)
  port ||= DEFAULT_NETTY_PORT
  return java.lang.Integer.new(port)
end

.require_jar(jar_name) ⇒ Object

Allow override of our included jars so we don’t have to keep up with hornetq releases



15
16
17
18
19
20
21
# File 'lib/hornetq.rb', line 15

def self.require_jar(jar_name)
  if ENV['HORNETQ_HOME']
    require "#{ENV['HORNETQ_HOME']}/lib/#{jar_name}.jar"
  else
    require "hornetq/java/#{jar_name}.jar"
  end
end

.ruby_logger(level = nil, target = STDOUT) ⇒ Object

Use the ruby logger, but add needed trace level logging which will result in debug log entries



23
24
25
26
27
28
29
30
31
# File 'lib/hornetq/common/logging.rb', line 23

def self.ruby_logger(level=nil, target=STDOUT)
  require 'logger'

  l = ::Logger.new(target)
  l.instance_eval "alias :trace :debug"
  l.instance_eval "alias :trace? :debug?"
  l.level = level || ::Logger::INFO
  l
end