First, thank you for any help you can provide.
The issue:
The jruby version of this java app will not output callbacks in the
running
thread…or to the running command line process. The java version works,
but
the ruby version goes straight to the command line and waits for more
user
input instead of waiting and outputting server responses. The code will
probably explain it better:
Java version
public class FeedSubscriberPublisher implements PFSubscriber {
DFConn _dfConn; // Connection to the establishment server
(authentication etc)
PFConn _pfConn; // Connection to the feed event server
public FeedSubscriberPublisher(DFConn df) {
_dfConn = df;
_pfConn = FSStarter.startConn(_dfConn, this);
_pfConn.start();
System.out.println(“Subscribing to event PFEventFeedUpdate…”);
_psConn.subscribe(“PFEventFeedUpdate”);
}
public void newEvent(PFEvent event) {
System.out.println("Feed Details: " + event);
}
public static void main(String args[]) {
DFConn df = null;
df = Establisher.connect(args, "FeedSubscriberPublisher");
FeedSubscriberPublisher sub = new FeedSubscriberPublisher(df);
}
}
Ruby Version:
df = Java::Establisher.connect(user_pass_etc, “FeedSubscriberPublisher”)
pfconn = Java::FSStarter.startConn(df, self)
pfconn.start
puts “Subscribing to Feed events”
pfconn.subscribe(“PFEventFeedUpdate”)
def newEvent(event)
puts event
end
The Ruby version breaks when providing ‘self’ as the ‘this’ equivalent
when
connecting(line two in the ruby script, here it is in IRB):
irb(main):007:0> pfconn = Java:: FSStarter.startConn(df, self)
NameError: no method ‘startConn’ with arguments matching [
com.feed.service.DFConn, org.jruby.RubyObject]
from
/Users/enebo/jruby/releases/jruby-0_9_8/src/builtin/javasupport.rb:579:in
matching_method' from /Users/enebo/jruby/releases/jruby-0_9_8/src/builtin/javasupport.rb:126:in
startConn’
from
/Users/enebo/jruby/releases/jruby-0_9_8/src/builtin/javasupport.rb:85:in
startConn' from (irb):1:in
binding’
And when I don’t provide ‘self’ at all, it throws no errors however it
never
seems to wait for client input. I.e:
irb(main):009:0> df = Java::Establisher.connect(user_pass_etc,
“FeedSubscriberPublisher”)
irb(main):010:0> pfconn = Java::FSStarter.startConn(df)
=> #<#Class:01x1f38c53:0x2cd1fc6 @java_object=
com.feed.service.DFConn@73cb02>
irb(main):011:0> pfconn.start
=> nil
irb(main):012:0> pfconn.subscribe(“PFEventFeedUpdate”)
=> nil
irb(main):013:0> def newEvent(event)
irb(main):014:1> puts event.toString
irb(main):015:1> end
=> nil
irb(main):016:0> puts “Why can I type here? I want this thing to stop
accepting input and start ouputting callbacks from the server!”
Why can I type here? I want this thing to stop accepting input and start
ouputting callbacks from the server!
=> nil
irb(main):017:0>
I’m not very familiar with java as you can probably tell. What gives?
Surely
it’s a simple fix I’m not grasping.
Thanks for any help or insight you could provide.