I believe this commit broke the javascript build. I'm guessing you didn't have the javascript build enabled when you tested this?
--Rafael On Mon, Feb 16, 2015 at 2:20 PM, <[email protected]> wrote: > Repository: qpid-proton > Updated Branches: > refs/heads/master cb5023d60 -> 913a6fb6b > > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/reactor-logger.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/reactor-logger.py > b/examples/reactor/py/reactor-logger.py > deleted file mode 100755 > index c07e9b9..0000000 > --- a/examples/reactor/py/reactor-logger.py > +++ /dev/null > @@ -1,54 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import time > -from proton.reactor import Reactor > - > -class Logger: > - > - def on_unhandled(self, name, event): > - print "LOG:", name, event > - > -class Program: > - > - def on_reactor_init(self, event): > - print "Hello, World!" > - > - def on_reactor_final(self, event): > - print "Goodbye, World!" > - > -# You can pass multiple handlers to a reactor when you construct it. > -# Each of these handlers will see every event the reactor sees. By > -# combining this with on_unhandled, you can log each event that goes > -# to the reactor. > -r = Reactor(Program(), Logger()) > -r.run() > - > -# Note that if you wanted to add the logger later, you could also > -# write the above as below. All arguments to the reactor are just > -# added to the default handler for the reactor. > - > -def logging_enabled(): > - return False > - > -r = Reactor(Program()) > -if logging_enabled(): > - r.handler.add(Logger()) > -r.run() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/recv.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/recv.py b/examples/reactor/py/recv.py > deleted file mode 100755 > index aa56472..0000000 > --- a/examples/reactor/py/recv.py > +++ /dev/null > @@ -1,48 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -from proton import Message > -from proton.reactor import Reactor > -from proton.handlers import CHandshaker, CFlowController > - > -class Program: > - > - def __init__(self): > - self.handlers = [CHandshaker(), CFlowController()] > - self.message = Message() > - > - def on_reactor_init(self, event): > - # Create an amqp acceptor. > - event.reactor.acceptor("0.0.0.0", 5672) > - # There is an optional third argument to the Reactor.acceptor > - # call. Using it, we could supply a handler here that would > - # become the handler for all accepted connections. If we omit > - # it, the reactor simply inherets all the connection events. > - > - def on_delivery(self, event): > - # XXX: we could make rcv.recv(self.message) work here to > - # compliment the similar thing on send > - rcv = event.receiver > - if rcv and self.message.recv(rcv): > - print self.message > - event.delivery.settle() > - > -r = Reactor(Program()) > -r.run() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/scheduling.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/scheduling.py > b/examples/reactor/py/scheduling.py > deleted file mode 100755 > index f822f68..0000000 > --- a/examples/reactor/py/scheduling.py > +++ /dev/null > @@ -1,51 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import time > -from proton.reactor import Reactor > - > -class Program: > - > - def on_reactor_init(self, event): > - self.start = time.time() > - print "Hello, World!" > - > - # We can schedule a task event for some point in the future. > - # This will cause the reactor to stick around until it has a > - # chance to process the event. > - > - # The first argument is the delay. The second argument is the > - # handler for the event. We are just using self for now, but > - # we could pass in another object if we wanted. > - task = event.reactor.schedule(1.0, self) > - > - # We can ignore the task if we want to, but we can also use it > - # to pass stuff to the handler. > - task.something_to_say = "Yay" > - > - def on_timer_task(self, event): > - task = event.context # xxx: don't have a task property on event > yet > - print task.something_to_say, "my task is complete!" > - > - def on_reactor_final(self, event): > - print "Goodbye, World! (after %s long seconds)" % (time.time() - > self.start) > - > -r = Reactor(Program()) > -r.run() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/send.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/send.py b/examples/reactor/py/send.py > deleted file mode 100755 > index 7b95502..0000000 > --- a/examples/reactor/py/send.py > +++ /dev/null > @@ -1,87 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import sys > -from proton import Message > -from proton.reactor import Reactor > -from proton.handlers import CHandshaker > - > -# This is a send in terms of low level AMQP events. There are handlers > -# that can streamline this significantly if you don't want to worry > -# about all the details, but it is useful to see how the AMQP engine > -# classes interact with handlers and events. > - > -class Send: > - > - def __init__(self, host, message): > - self.host = host > - self.message = message > - # Use the handlers property to add some default handshaking > - # behaviour. > - self.handlers = [CHandshaker()] > - > - def on_connection_init(self, event): > - conn = event.connection > - conn.hostname = self.host > - > - # Every session or link could have their own handler(s) if we > - # wanted simply by setting the "handler" slot on the > - # given session or link. > - ssn = conn.session() > - > - # If a link doesn't have an event handler, the events go to > - # its parent session. If the session doesn't have a handler > - # the events go to its parent connection. If the connection > - # doesn't have a handler, the events go to the reactor. > - snd = ssn.sender("sender") > - conn.open() > - ssn.open() > - snd.open() > - > - def on_link_flow(self, event): > - snd = event.sender > - if snd.credit > 0: > - dlv = snd.send(self.message) > - dlv.settle() > - snd.close() > - snd.session.close() > - snd.connection.close() > - > -class Program: > - > - def __init__(self, hostname, content): > - self.hostname = hostname > - self.content = content > - > - def on_reactor_init(self, event): > - # You can use the connection method to create AMQP connections. > - > - # This connection's handler is the Send object. All the events > - # for this connection will go to the Send object instead of > - # going to the reactor. If you were to omit the Send object, > - # all the events would go to the reactor. > - event.reactor.connection(Send(self.hostname, > Message(self.content))) > - > -args = sys.argv[1:] > -hostname = args.pop() if args else "localhost" > -content = args.pop() if args else "Hello World!" > - > -r = Reactor(Program(hostname, content)) > -r.run() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/tornado-hello-world.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/tornado-hello-world.py > b/examples/reactor/py/tornado-hello-world.py > deleted file mode 100755 > index fa8ca83..0000000 > --- a/examples/reactor/py/tornado-hello-world.py > +++ /dev/null > @@ -1,41 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import tornado.ioloop > -from tornado_app import TornadoApp > - > -# The proton reactor provides a general purpose event processing > -# library for writing reactive programs. A reactive program is defined > -# by a set of event handlers. An event handler is just any class or > -# object that defines the "on_<event>" methods that it cares to > -# handle. > - > -class Program: > - > - # The reactor init event is produced by the reactor itself when it > - # starts. > - def on_reactor_init(self, event): > - print "Hello, World!" > - > -# The TornadoApp integrates a Reactor into tornado's ioloop. > -TornadoApp(Program()) > - > -# Now the tornado main loop will behave like the reactor's main loop. > -tornado.ioloop.IOLoop.instance().start() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/tornado-send.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/tornado-send.py > b/examples/reactor/py/tornado-send.py > deleted file mode 100755 > index 54b8618..0000000 > --- a/examples/reactor/py/tornado-send.py > +++ /dev/null > @@ -1,82 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import sys, tornado.ioloop > -from tornado_app import TornadoApp > -from proton import Message > -from proton.handlers import CHandshaker > - > -class Send: > - > - def __init__(self, host, message): > - self.host = host > - self.message = message > - # Use the handlers property to add some default handshaking > - # behaviour. > - self.handlers = [CHandshaker()] > - > - def on_connection_init(self, event): > - conn = event.connection > - conn.hostname = self.host > - > - # Every session or link could have their own handler(s) if we > - # wanted simply by setting the "handler" slot on the > - # given session or link. > - ssn = conn.session() > - > - # If a link doesn't have an event handler, the events go to > - # its parent session. If the session doesn't have a handler > - # the events go to its parent connection. If the connection > - # doesn't have a handler, the events go to the reactor. > - snd = ssn.sender("sender") > - conn.open() > - ssn.open() > - snd.open() > - > - def on_link_flow(self, event): > - snd = event.sender > - if snd.credit > 0: > - dlv = snd.send(self.message) > - dlv.settle() > - snd.close() > - snd.session.close() > - snd.connection.close() > - > -class Program: > - > - def __init__(self, hostname, content): > - self.hostname = hostname > - self.content = content > - > - def on_reactor_init(self, event): > - # You can use the connection method to create AMQP connections. > - > - # This connection's handler is the Send object. All the events > - # for this connection will go to the Send object instead of > - # going to the reactor. If you were to omit the Send object, > - # all the events would go to the reactor. > - event.reactor.connection(Send(self.hostname, > Message(self.content))) > - > -args = sys.argv[1:] > -hostname = args.pop() if args else "localhost" > -content = args.pop() if args else "Hello World!" > - > -TornadoApp(Program(hostname, content)) > -tornado.ioloop.IOLoop.instance().start() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/tornado_app.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/tornado_app.py > b/examples/reactor/py/tornado_app.py > deleted file mode 100644 > index 966ac8b..0000000 > --- a/examples/reactor/py/tornado_app.py > +++ /dev/null > @@ -1,93 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import tornado.ioloop > -from proton.reactor import Reactor > -from proton.handlers import IOHandler > - > -class TornadoApp: > - > - def __init__(self, *args): > - self.reactor = Reactor(*args) > - self.reactor.global_handler = self > - self.io = IOHandler() > - self.loop = tornado.ioloop.IOLoop.instance() > - self.count = 0 > - self.reactor.start() > - self.reactor.process() > - > - def on_reactor_quiesced(self, event): > - event.reactor.yield_() > - > - def on_unhandled(self, name, event): > - event.dispatch(self.io) > - > - def _events(self, sel): > - events = self.loop.ERROR > - if sel.reading: > - events |= self.loop.READ > - if sel.writing: > - events |= self.loop.WRITE > - return events > - > - def _schedule(self, sel): > - if sel.deadline: > - self.loop.add_timeout(sel.deadline, lambda: self.expired(sel)) > - > - def _expired(self, sel): > - sel.expired() > - > - def _process(self): > - self.reactor.process() > - if not self.reactor.quiesced: > - self.loop.add_callback(self._process) > - > - def _callback(self, sel, events): > - if self.loop.READ & events: > - sel.readable() > - if self.loop.WRITE & events: > - sel.writable() > - self._process() > - > - def on_selectable_init(self, event): > - sel = event.context > - if sel.fileno() >= 0: > - self.loop.add_handler(sel.fileno(), lambda fd, events: > self._callback(sel, events), self._events(sel)) > - self._schedule(sel) > - self.count += 1 > - > - def on_selectable_updated(self, event): > - sel = event.context > - if sel.fileno() > 0: > - self.loop.update_handler(sel.fileno(), self._events(sel)) > - self._schedule(sel) > - > - def on_selectable_final(self, event): > - sel = event.context > - if sel.fileno() > 0: > - self.loop.remove_handler(sel.fileno()) > - sel.release() > - self.count -= 1 > - if self.count == 0: > - self.loop.add_callback(self._stop) > - > - def _stop(self): > - self.reactor.stop() > - self.loop.stop() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/reactor/py/unhandled.py > ---------------------------------------------------------------------- > diff --git a/examples/reactor/py/unhandled.py > b/examples/reactor/py/unhandled.py > deleted file mode 100755 > index 3734a71..0000000 > --- a/examples/reactor/py/unhandled.py > +++ /dev/null > @@ -1,34 +0,0 @@ > -#!/usr/bin/python > -# > -# Licensed to the Apache Software Foundation (ASF) under one > -# or more contributor license agreements. See the NOTICE file > -# distributed with this work for additional information > -# regarding copyright ownership. The ASF licenses this file > -# to you under the Apache License, Version 2.0 (the > -# "License"); you may not use this file except in compliance > -# with the License. You may obtain a copy of the License at > -# > -# http://www.apache.org/licenses/LICENSE-2.0 > -# > -# Unless required by applicable law or agreed to in writing, > -# software distributed under the License is distributed on an > -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > -# KIND, either express or implied. See the License for the > -# specific language governing permissions and limitations > -# under the License. > -# > - > -import time > -from proton.reactor import Reactor > - > -class Program: > - > - # If an event occurs and its handler doesn't have an on_<event> > - # method, the reactor will attempt to call the on_unhandled method > - # if it exists. This can be useful not only for debugging, but for > - # logging and for delegating/inheritance. > - def on_unhandled(self, name, event): > - print name, event > - > -r = Reactor(Program()) > -r.run() > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/ruby/messenger/client.rb > ---------------------------------------------------------------------- > diff --git a/examples/ruby/messenger/client.rb > b/examples/ruby/messenger/client.rb > new file mode 100644 > index 0000000..571744c > --- /dev/null > +++ b/examples/ruby/messenger/client.rb > @@ -0,0 +1,92 @@ > +#!/usr/bin/env ruby > +# > +# Licensed to the Apache Software Foundation (ASF) under one > +# or more contributor license agreements. See the NOTICE file > +# distributed with this work for additional information > +# regarding copyright ownership. The ASF licenses this file > +# to you under the Apache License, Version 2.0 (the > +# "License"); you may not use this file except in compliance > +# with the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, > +# software distributed under the License is distributed on an > +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > +# KIND, either express or implied. See the License for the > +# specific language governing permissions and limitations > +# under the License. > +# > + > +require 'qpid_proton' > +require 'optparse' > + > + > +$options = { > + :verbose => false, > + :hostname => "0.0.0.0", > + :subject => "", > + :replyto => "~/replies" > +} > + > + > +OptionParser.new do |opts| > + opts.banner = "Usage: client [options] <addr> <subject>" > + > + opts.on("-r", "--reply-to", String, :REQUIRED, > + "Reply address") do |replyto| > + $options[:replyto] = replyto > + end > + > + opts.on("-v", "--verbose", :NONE, > + "Enable verbose output") do > + $options[:verbose] = true > + end > + > + opts.on("-h", "--help", :NONE, > + "Show this help message") do > + puts opts > + exit > + end > + > + begin > + ARGV << "-h" if ARGV.empty? > + opts.parse!(ARGV) > + rescue OptionParser::ParseError => error > + STDERR.puts error.message, "\n", opts > + exit 1 > + end > + > + ($options[:address], $options[:subject]) = ARGV > + > + abort "No address specified" if $options[:hostname].nil? > + abort "No subject specified" if $options[:subject].nil? > + > +end > + > +def log(text) > + printf "#{Time.new}: #{text}\n" if $options[:verbose] > +end > + > +msgr = Qpid::Proton::Messenger.new > +msgr.start > + > +msg = Qpid::Proton::Message.new > +msg.address = $options[:address] > +msg.subject = $options[:subject] > +msg.reply_to = $options[:replyto] > + > +msgr.put(msg) > +msgr.send > + > +if $options[:replyto].start_with? "~/" > + msgr.receive(1) > + begin > + msgr.get(msg) > + puts "#{msg.address}, #{msg.subject}" > + rescue error > + puts error > + end > +end > + > +msgr.stop > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/ruby/messenger/mailserver.rb > ---------------------------------------------------------------------- > diff --git a/examples/ruby/messenger/mailserver.rb > b/examples/ruby/messenger/mailserver.rb > new file mode 100644 > index 0000000..2d353ca > --- /dev/null > +++ b/examples/ruby/messenger/mailserver.rb > @@ -0,0 +1,85 @@ > +#!/usr/bin/env ruby > +# > +# Licensed to the Apache Software Foundation (ASF) under one > +# or more contributor license agreements. See the NOTICE file > +# distributed with this work for additional information > +# regarding copyright ownership. The ASF licenses this file > +# to you under the Apache License, Version 2.0 (the > +# "License"); you may not use this file except in compliance > +# with the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, > +# software distributed under the License is distributed on an > +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > +# KIND, either express or implied. See the License for the > +# specific language governing permissions and limitations > +# under the License. > +# > + > +require 'qpid_proton' > +require 'optparse' > + > +FAILED = 0 > +CONNECTION_UP = 1 > +AUTHENTICATING = 2 > + > +$options = { > + :verbose => false, > + :address => ["amqp://~0.0.0.0"], > +} > + > +OptionParser.new do |opts| > + opts.banner = "Usage: mailserver [options] <addr_1> ... <addr_n>" > + > + opts.on("-v", "--verbose", :NONE, > + "Print status messages to stdout") do |f| > + $options[:verbose] = true > + end > + > + opts.parse! > + > + if ARGV.length > 0 > + $options[:address] = [] > + ARGV.each {|address| $options[:address] << address} > + end > +end > + > +def log(text) > + STDOUT.puts "#{Time.new}: #{text}" if $options[:verbose] > +end > + > +msgr = Qpid::Proton::Messenger.new > +msgr.start > + > +$options[:address].each {|addr| msgr.subscribe(addr)} > + > +def dispatch(request, response) > + response.subject = "Re: #{request.subject}" if !request.subject.empty? > + response.properties = request.properties > + puts "Dispatched #{request.subject} #{request.properties}" > +end > + > +msg = Qpid::Proton::Message.new > +reply = Qpid::Proton::Message.new > + > +loop do > + msgr.receive(10) if msgr.incoming < 10 > + > + if msgr.incoming > 0 > + msgr.get(msg) > + if !msg.reply_to.nil? && !msg.reply_to.empty? > + puts msg.reply_to > + reply.address = msg.reply_to > + reply.correlation_id = msg.correlation_id > + reply.body = msg.body > + end > + dispatch(msg, reply) > + msgr.put(reply) > + msgr.send > + end > +end > + > +msgr.stop > + > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/ruby/messenger/passive_recv.rb > ---------------------------------------------------------------------- > diff --git a/examples/ruby/messenger/passive_recv.rb > b/examples/ruby/messenger/passive_recv.rb > new file mode 100644 > index 0000000..a3625ac > --- /dev/null > +++ b/examples/ruby/messenger/passive_recv.rb > @@ -0,0 +1,140 @@ > +#!/usr/bin/env ruby > +# > +# Licensed to the Apache Software Foundation (ASF) under one > +# or more contributor license agreements. See the NOTICE file > +# distributed with this work for additional information > +# regarding copyright ownership. The ASF licenses this file > +# to you under the Apache License, Version 2.0 (the > +# "License"); you may not use this file except in compliance > +# with the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, > +# software distributed under the License is distributed on an > +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > +# KIND, either express or implied. See the License for the > +# specific language governing permissions and limitations > +# under the License. > + > +require 'qpid_proton' > +require 'optparse' > + > +addresses = [] > + > +OptionParser.new do |opts| > + opts.banner = "Usage: recv.rb <addr1> ... <addrn>" > + opts.parse! > + > + addresses = ARGV > +end > + > +addresses = ["~0.0.0.0"] if addresses.empty? > + > +messenger = Qpid::Proton::Messenger.new > +messenger.passive = true > + > +begin > + messenger.start > +rescue ProtonError => error > + puts "ERROR: #{error.message}" > + puts error.backtrace.join("\n") > + exit > +end > + > +addresses.each do |address| > + begin > + messenger.subscribe(address) > + rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + exit > + end > +end > + > +msg = Qpid::Proton::Message.new > + > +read_array = [] > +write_array = [] > +selectables = {} > + > +loop do > + > + # wait for incoming messages > + sel = messenger.selectable > + while !sel.nil? > + if sel.terminal? > + selectables.delete(sel.fileno) > + read_array.delete(sel) > + write_array.delete(sel) > + sel.free > + else > + sel.capacity > + sel.pending > + if !sel.registered? > + read_array << sel > + write_array << sel > + selectables[sel.fileno] = sel > + sel.registered = true > + end > + end > + sel = messenger.selectable > + end > + > + unless selectables.empty? > + rarray = []; read_array.each {|fd| rarray << fd.to_io } > + warray = []; write_array.each {|fd| warray << fd.to_io } > + > + if messenger.deadline > 0.0 > + result = IO.select(rarray, warray, nil, messenger.deadline) > + else > + result = IO.select(rarray, warray) > + end > + > + unless result.nil? && result.empty? > + result.flatten.each do |io| > + sel = selectables[io.fileno] > + > + sel.writable if sel.pending > 0 > + sel.readable if sel.capacity > 0 > + end > + end > + > + begin > + messenger.receive(10) > + rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + exit > + end > + > + while messenger.incoming.nonzero? > + begin > + messenger.get(msg) > + rescue Qpid::Proton::Error => error > + puts "ERROR: #{error.message}" > + exit > + end > + > + puts "Address: #{msg.address}" > + subject = msg.subject || "(no subject)" > + puts "Subject: #{subject}" > + puts "Body: #{msg.body}" > + puts "Properties: #{msg.properties}" > + puts "Instructions: #{msg.instructions}" > + puts "Annotations: #{msg.annotations}" > + > + if msg.reply_to > + puts "=== Sending a reply to #{msg.reply_to}" > + reply = Qpid::Proton::Message.new > + reply.address = msg.reply_to > + reply.subject = "RE: #{msg.subject}" > + reply.content = "Thanks for the message!" > + > + messenger.put(reply) > + messenger.send > + end > + end > + end > +end > + > +messenger.stop > + > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/ruby/messenger/recv.rb > ---------------------------------------------------------------------- > diff --git a/examples/ruby/messenger/recv.rb > b/examples/ruby/messenger/recv.rb > new file mode 100644 > index 0000000..4e464f1 > --- /dev/null > +++ b/examples/ruby/messenger/recv.rb > @@ -0,0 +1,82 @@ > +#!/usr/bin/env ruby > +# > +# Licensed to the Apache Software Foundation (ASF) under one > +# or more contributor license agreements. See the NOTICE file > +# distributed with this work for additional information > +# regarding copyright ownership. The ASF licenses this file > +# to you under the Apache License, Version 2.0 (the > +# "License"); you may not use this file except in compliance > +# with the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, > +# software distributed under the License is distributed on an > +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > +# KIND, either express or implied. See the License for the > +# specific language governing permissions and limitations > +# under the License. > + > +require 'qpid_proton' > +require 'optparse' > + > +addresses = [] > + > +OptionParser.new do |opts| > + opts.banner = "Usage: recv.rb <addr1> ... <addrn>" > + opts.parse! > + > + addresses = ARGV > +end > + > +addresses = ["~0.0.0.0"] if addresses.empty? > + > +messenger = Qpid::Proton::Messenger.new > + > +begin > + messenger.start > +rescue ProtonError => error > + puts "ERROR: #{error.message}" > + puts error.backtrace.join("\n") > + exit > +end > + > +addresses.each do |address| > + begin > + messenger.subscribe(address) > + rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + exit > + end > +end > + > +msg = Qpid::Proton::Message.new > + > +loop do > + begin > + messenger.receive(10) > + rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + exit > + end > + > + while messenger.incoming.nonzero? > + begin > + messenger.get(msg) > + rescue Qpid::Proton::Error => error > + puts "ERROR: #{error.message}" > + exit > + end > + > + puts "Address: #{msg.address}" > + subject = msg.subject || "(no subject)" > + puts "Subject: #{subject}" > + puts "Body: #{msg.body}" > + puts "Properties: #{msg.properties}" > + puts "Instructions: #{msg.instructions}" > + puts "Annotations: #{msg.annotations}" > + end > +end > + > +messenger.stop > + > > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/examples/ruby/messenger/send.rb > ---------------------------------------------------------------------- > diff --git a/examples/ruby/messenger/send.rb > b/examples/ruby/messenger/send.rb > new file mode 100644 > index 0000000..81ce733 > --- /dev/null > +++ b/examples/ruby/messenger/send.rb > @@ -0,0 +1,74 @@ > +#!/usr/bin/env ruby > +# > +# Licensed to the Apache Software Foundation (ASF) under one > +# or more contributor license agreements. See the NOTICE file > +# distributed with this work for additional information > +# regarding copyright ownership. The ASF licenses this file > +# to you under the Apache License, Version 2.0 (the > +# "License"); you may not use this file except in compliance > +# with the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, > +# software distributed under the License is distributed on an > +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > +# KIND, either express or implied. See the License for the > +# specific language governing permissions and limitations > +# under the License. > + > +require 'qpid_proton' > +require 'optparse' > + > +options = {} > +messages = [] > + > +OptionParser.new do |opts| > + opts.banner = "Usage: send.rb [options] <msg1> ... <msgn>" > + opts.on("-a", "--address [addr]", "The receiver's address (def. > 0.0.0.0)") do |f| > + options[:address] = f > + end > + > + opts.parse! > + > + messages = ARGV > +end > + > +options[:address] = "0.0.0.0" unless options[:address] > +messages << "Hello world!" if messages.empty? > + > +messenger = Qpid::Proton::Messenger.new > +messenger.start > +msg = Qpid::Proton::Message.new > + > +messages.each do |message| > + msg.address = options[:address] > + msg.subject = "How are you?" > + msg["sent"] = Time.new > + msg["hostname"] = ENV["HOSTNAME"] > + msg.instructions["fold"] = "yes" > + msg.instructions["spindle"] = "no" > + msg.instructions["mutilate"] = "no" > + msg.annotations["version"] = 1.0 > + msg.annotations["pill"] = :RED > + msg.body = message > + > + begin > + messenger.put(msg) > + rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + exit > + end > +end > + > +begin > + messenger.send > +rescue Qpid::Proton::ProtonError => error > + puts "ERROR: #{error.message}" > + puts error.backtrace.join("\n") > + exit > +end > + > +puts "SENT: " + messages.join(",") > + > +messenger.stop > > http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/913a6fb6/pom.xml > ---------------------------------------------------------------------- > diff --git a/pom.xml b/pom.xml > index 47ef4c6..412af45 100644 > --- a/pom.xml > +++ b/pom.xml > @@ -98,7 +98,7 @@ > <module>contrib/proton-jms</module> > <module>contrib/proton-hawtdispatch</module> > <module>tests</module> > - <module>examples/messenger/java</module> > + <module>examples/java/messenger</module> > </modules> > > <url>http://qpid.apache.org/proton</url> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
