Skip to content

Instantly share code, notes, and snippets.

@arkadiyk
Created January 19, 2012 04:09
Show Gist options
  • Save arkadiyk/1637793 to your computer and use it in GitHub Desktop.
Save arkadiyk/1637793 to your computer and use it in GitHub Desktop.
Call tibco EMS from JRuby
include Java
require "#{ENV['TIB_LIBS']}/wljmsclient.jar"
require "#{ENV['TIB_LIBS']}/wlclient.jar"
require "#{ENV['TIB_LIBS']}/tibjms.jar"
PROVIDER_URL = 'tcp://JEUP-EQ-A.aaaaaa.com:42669,tcp://JEUP-EQ-B.aaaaaa.com:42669'
class MetreosJmsHandler
import java.util.Hashtable
import javax.jms.Session
import javax.naming.InitialContext
import javax.naming.Context
include javax.jms.MessageListener
def onMessage(serialized_message)
state = serialized_message.text[/<State>(.*)<\/State>/,1]
@buffer.put state
end
def initialize buffer
@buffer = buffer
env = {
Context::INITIAL_CONTEXT_FACTORY => "com.tibco.tibjms.naming.TibjmsInitialContextFactory",
Context::PROVIDER_URL => PROVIDER_URL,
Context::SECURITY_PRINCIPAL => "",
Context::SECURITY_CREDENTIALS => ""
}
ctx = InitialContext.new(Hashtable.new(env))
con_factory = ctx.lookup("FQFTTopicConnectionFactory")
jms_con = con_factory.create_topic_connection("","")
@session = jms_con.create_topic_session(false, Session::AUTO_ACKNOWLEDGE)
@jms_topic = ctx.lookup("CRM.DIALER.TOPIC.PROD")
jms_con.start
end
def subscribe(session_id)
@subscriber.close unless @subscriber.nil?
@subscriber = @session.create_subscriber(@jms_topic, "JMSCorrelationID='sessionId=#{session_id}'",false)
@subscriber.set_message_listener(self)
end
def unsubscribe
@subscriber.close
end
end
@mahesh80
Copy link

Hi,

I am trying to connect the tybco to read the messages which we are dripping. When I ran the code which was provided by you, I am getting the follwing error:
LoadError: no such file to load -- /wljmsclient
require at org/jruby/RubyKernel.java:1065
require at D:/jruby-1.7.13/lib/ruby/shared/rubygems/core_ext/kernel_require.rb
:55
(root) at program1.rb:3

Can you please guide me to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment