 |
Forums |
Admin Discussion Forums: help Start New Thread
| Message: 69329 |
 |
BY: santosh solapurkar (sansolapurkar) DATE: 2009-04-26 11:08 SUBJECT: Using RJB to send XML file to Weblogic JMS Well what i am trying to is send messages to Weblogic JMS Queue with ruby as i am attempting to automate web application which uses JMS as interface.
I did see JRuby as option and was able to search some coding done on this also a whole bunch of Lib WMQ which is for websphere MQ.but as Jruby methods cannot be called in conventional ruby and needs some wrapper to be written (Seen posting on Jwatir) which leads to more of coading. Where as RJB doesnot have this issue we can call RJB code from conventional Ruby. So did i go with it and started putting some code which is messy right now.
I am able to successfully connect to the weblogic JMS as this doesnot throw ConnectionException. But when trying to send message to Queue i am getting error "`send': #<#<Class:0x2dcb660>:0x2dc8adc> is not a symbol (TypeError) from TestJms.rb:55
which i guess is because of the data type missmatch. But when i invove message.getText() then i get approprate data in XML file which does mean the message object has been set correct. I am not able to figure out what exactly is causing this. Below is spec of code that i have written. Please let me know if there is any way we can remove this error.
##################################################################################################
require 'rjb'
Rjb::load("C:/ruby/jms.jar;C:/ruby/weblogic.jar")
Context = Rjb::import("javax.naming.Context")
InitialContext = Rjb::import("javax.naming.InitialContext")
MessageListener = Rjb::import("javax.jms.MessageListener")
Hastbl = Rjb::import("java.util.Hashtable")
NamingException=Rjb::import("javax.naming.NamingException")
PortableObj=Rjb::import("javax.rmi.PortableRemoteObject")
QueueConFac = Rjb::import("javax.jms.QueueConnectionFactory")
QueueConn = Rjb::import("javax.jms.QueueConnection")
Qsession= Rjb::import("javax.jms.QueueSession")
Qsender = Rjb::import("javax.jms.QueueSender")
Tpublisher = Rjb::import("javax.jms.TopicPublisher")
Queues = Rjb::import("javax.jms.Queue")
Tmsg = Rjb::import("javax.jms.TextMessage")
Session = Rjb::import("javax.jms.Session")
String1 = Rjb::import("java.lang.String")
JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory"
# Parameters
JMS_FACTORY = "ConnectionFactory"; # e.g. weblogic.sandbox.connectionFactory
QUEUE = "ContractInbound"; # e.g. weblogic.sandbox.topic
URL = "t3://10.233.0.123:8005/esmeim"; # e.g. t3://192.168.249.128:7001
env = Hastbl.new()
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, URL);
env.put("weblogic.jndi.createIntermediateContexts", "true");
ctx = InitialContext.new(env)
puts ctx
factory=ctx.lookup(JMS_FACTORY)
puts factory
@connection = factory.createQueueConnection()
puts @connection
@Qsession1 = @connection.createQueueSession(false, Qsession.AUTO_ACKNOWLEDGE)
QueueSet = ctx.lookup(QUEUE)
qsender = @Qsession1.createSender(QueueSet)
puts @Qsession1
filename = "Contract_The Guidance_Center_Inc_Cost_TC_22_C.xml"
@connection.start
data =""
f = File.open(filename, "r")
f.each_line do |line|
data += line
end
msg = String1.new()
msg = data
message = @Qsession1.createTextMessage()
message.setText(msg)
puts message.getText()
qsender.send(message)
@connection.close
##################################################################################################
| |
Thread View
Post a followup to this message
|
 |