activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1410349 - in /activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python: ./ stompest/ stompest/async/ stompest/sync/ stomppy/
Date Fri, 16 Nov 2012 14:14:05 GMT
Author: chirino
Date: Fri Nov 16 14:14:03 2012
New Revision: 1410349

URL: http://svn.apache.org/viewvc?rev=1410349&view=rev
Log:
APLO-268: Added examples for stompest Python STOMP client

Added:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/__init__.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/listener.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/publisher.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/readme.md
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/__init__.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/listener.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/publisher.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/listener.py
      - copied, changed from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/listener.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/publisher.py
      - copied, changed from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/publisher.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/readme.md
      - copied, changed from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md
Removed:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/listener.py
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/publisher.py
Modified:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md?rev=1410349&r1=1410348&r2=1410349&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md
(original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md
Fri Nov 16 14:14:03 2012
@@ -1,10 +1,7 @@
-Prereqs
-=======
+Overview
+========
 
-Install the [stomppy](http://code.google.com/p/stomppy) python client
-library.
-
-easy_install users can install it by running:
-
-     easy_install http://stomppy.googlecode.com/files/stomp.py-3.0.2a.tar.gz
+Python users can choose between examples for the following client libraries:
 
+* [stomppy](http://code.google.com/p/stomppy) 
+* [stompest](https://github.com/nikipore/stompest)

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/__init__.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/__init__.py?rev=1410349&view=auto
==============================================================================
    (empty)

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/listener.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/listener.py?rev=1410349&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/listener.py
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/listener.py
Fri Nov 16 14:14:03 2012
@@ -0,0 +1,65 @@
+#!/usr/bin/env 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 os
+import sys
+import time
+
+from twisted.internet import defer, reactor
+
+from stompest.config import StompConfig
+from stompest.async import Stomp
+
+user = os.getenv('STOMP_USER') or 'admin'
+password = os.getenv('STOMP_PASSWORD') or 'password'
+host = os.getenv('STOMP_HOST') or 'localhost'
+port = int(os.getenv('STOMP_PORT') or 61613)
+destination = sys.argv[1:2] or ['/topic/event']
+destination = destination[0]
+
+messages = 10000
+
+class Listener(object):
+    @defer.inlineCallbacks
+    def run(self):
+        config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password,
version='1.1')
+        client = Stomp(config)
+        yield client.connect(host='mybroker')
+        
+        self.count = 0
+        self.start = time.time()
+        client.subscribe(destination, self.handleFrame, headers={'ack': 'auto', 'id': 'required-for-STOMP-1.1'},
ack=False)
+        
+    @defer.inlineCallbacks
+    def handleFrame(self, client, frame):
+        self.count += 1
+        if self.count == messages:
+            self.stop(client)
+    
+    @defer.inlineCallbacks
+    def stop(self, client):
+        print 'Disconnecting. Waiting for RECEIPT frame ...',
+        yield client.disconnect(receipt='bye')
+        print 'ok'
+        
+        diff = time.time() - self.start
+        print 'Received %s frames in %f seconds' % (self.count, diff)
+        reactor.stop()
+
+if __name__ == '__main__':
+    Listener().run()
+    reactor.run()

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/publisher.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/publisher.py?rev=1410349&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/publisher.py
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/async/publisher.py
Fri Nov 16 14:14:03 2012
@@ -0,0 +1,57 @@
+#!/usr/bin/env 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 os
+import sys
+import time
+
+from twisted.internet import defer, reactor
+
+from stompest.config import StompConfig
+from stompest.async import Stomp
+
+user = os.getenv('STOMP_USER') or 'admin'
+password = os.getenv('STOMP_PASSWORD') or 'password'
+host = os.getenv('STOMP_HOST') or 'localhost'
+port = int(os.getenv('STOMP_PORT') or 61613)
+destination = sys.argv[1:2] or ['/topic/event']
+destination = destination[0]
+
+messages = 10000
+data = 'Hello World from Python'
+
+@defer.inlineCallbacks
+def run():
+    config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
+    client = Stomp(config)
+    yield client.connect(host='mybroker')
+
+    count = 0
+    start = time.time()
+    
+    for _ in xrange(messages):
+        client.send(destination=destination, body=data, headers={'persistent': 'false'})
+        count += 1
+
+    diff = time.time() - start
+    print 'Sent %s frames in %f seconds' % (count, diff)
+  
+    yield client.disconnect(receipt='bye')
+
+if __name__ == '__main__':
+    run()
+    reactor.run()

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/readme.md?rev=1410349&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/readme.md
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/readme.md
Fri Nov 16 14:14:03 2012
@@ -0,0 +1,14 @@
+Prereqs
+=======
+
+Install the [stomppy](http://code.google.com/p/stomppy) python client
+library.
+
+easy_install users can install it by running:
+
+     easy_install stompest
+
+The stompest client library supports a blocking API, and you can find an
+example of it's use in the `sync` directory.  It also supports using 
+a non-blocking API based on Twisted, and that example can be found in 
+the `async` directory.
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/__init__.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/__init__.py?rev=1410349&view=auto
==============================================================================
    (empty)

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/listener.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/listener.py?rev=1410349&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/listener.py
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/listener.py
Fri Nov 16 14:14:03 2012
@@ -0,0 +1,50 @@
+#!/usr/bin/env 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 os
+import sys
+import time
+
+from stompest.config import StompConfig
+from stompest.sync import Stomp
+
+user = os.getenv('STOMP_USER') or 'admin'
+password = os.getenv('STOMP_PASSWORD') or 'password'
+host = os.getenv('STOMP_HOST') or 'localhost'
+port = int(os.getenv('STOMP_PORT') or 61613)
+destination = sys.argv[1:2] or ['/topic/event']
+destination = destination[0]
+
+config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
+client = Stomp(config)
+
+client.connect(host='mybroker')
+client.subscribe(destination=destination, headers={'id': 'required-for-STOMP-1.1'})
+
+count = 0
+start = time.time()
+
+while (not count) or client.canRead(0):
+    client.receiveFrame()
+    count += 1
+
+diff = time.time() - start
+print 'Received %s frames in %f seconds' % (count, diff)
+
+client.disconnect(receipt='bye')
+client.receiveFrame()
+client.close()
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/publisher.py
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/publisher.py?rev=1410349&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/publisher.py
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stompest/sync/publisher.py
Fri Nov 16 14:14:03 2012
@@ -0,0 +1,51 @@
+#!/usr/bin/env 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 os
+import sys
+import time
+
+from stompest.config import StompConfig
+from stompest.sync import Stomp
+
+user = os.getenv('STOMP_USER') or 'admin'
+password = os.getenv('STOMP_PASSWORD') or 'password'
+host = os.getenv('STOMP_HOST') or 'localhost'
+port = int(os.getenv('STOMP_PORT') or 61613)
+destination = sys.argv[1:2] or ['/topic/event']
+destination = destination[0]
+
+messages = 10000
+data = 'Hello World from Python'
+
+config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
+client = Stomp(config)
+client.connect(host='mybroker')
+
+count = 0
+start = time.time()
+
+for _ in xrange(messages):
+    client.send(destination=destination, body=data, headers={'persistent': 'false'})
+    count += 1
+
+diff = time.time() - start
+print 'Sent %s frames in %f seconds' % (count, diff)
+  
+client.disconnect(receipt='bye')
+client.receiveFrame()
+client.close()
\ No newline at end of file

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/listener.py
(from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/listener.py)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/listener.py?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/listener.py&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/listener.py&r1=1410101&r2=1410349&rev=1410349&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/publisher.py
(from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/publisher.py)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/publisher.py?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/publisher.py&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/publisher.py&r1=1410101&r2=1410349&rev=1410349&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/readme.md
(from r1410101, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/readme.md?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/stomppy/readme.md&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/stomp/python/readme.md&r1=1410101&r2=1410349&rev=1410349&view=diff
==============================================================================
    (empty)



Mime
View raw message