 |
Forums |
Admin Discussion Forums: help Start New Thread
By: t g
RE: Using RJB to send XML file to Weblogic JMS [ reply ] 2012-07-16 23:04
|
I ran into the same problem, only using ActiveMQ instead of Weblogic JMS. Another way to solve this is using the "_invoke" method.
producer._invoke('send', 'Ljavax.jms.Message;', mapmsg)
PS I realize this is a very old thread, but happened to pop up right at the top of my Google search and was relevant ....
|
By: santosh solapurkar
RE: Using RJB to send XML file to Weblogic JMS [ reply ] 2009-04-26 20:51
|
I guess i found the issue. The method send which transports message to a queue/topic belonging to producer is getting conflicting with the obj.send(symbol [, args...]) => obj message of ruby Obj (0bject class). I did try to use method __send__ which is still throwing the same error.
Apart from this i also tried to use _invoke method to invoke send method like this.
producer._invoke('send',"javax.jms.Queue;javax.jms.Message;",QueueSet,message)
which throws error
TestJMSUsingProducer.rb:57:in `_invoke': Fail: unknown method name `send('javax.jms.Queue;javax.jms.Message;')' (RuntimeError)
I guess the invoke method is not able to find the send method and hence throwing this error.
Can any one suggest what i am missing.
Thanks In advance
|
By: santosh solapurkar
Using RJB to send XML file to Weblogic JMS [ reply ] 2009-04-26 11:08
|
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
##################################################################################################
|
|
 |