WebSockets, AMQP, Where to Place Code

55 views
Skip to first unread message

Phil

unread,
Jan 18, 2015, 6:17:10 PM1/18/15
to web...@googlegroups.com
Caveat: I am not knowledgeable about web development.

Situation: Our company develops IoT software enabling IoT product developers to easily connect their sensors to a backend datastore through amqp. Recently, a key player left and I must complete a demonstration that allows configuration of data channels and renders charts through a connection between amqp subscribed channels and web2py websockets (I understand these).  We have developed our web using web2py which runs on GAE.  We are importing pika from a local installation into python which I am assuming requires us to install the amqplib directly into web2py for GAE.

Problem: I have tried many different methods of integrating our web2py web with our software and amqp. 
  1. placing our software in gluon.contrib.chimeraiot and the amqp code under gluon.contrib.amqp. (complete change in imports never worked)
  2. placing all modules in modules worked locally but not on GAE
  3. placing all modules in gluon.  Did not work for me
I read the following from a great logstash handler that I thinks has the clue to what to do.  Any help would be appreciated.

###Preface - Recommended dependency management procedure on GAE
It is recommended that you follow a dependency management procedure in which you have a folder for third-party dependencies adjacent to your application code folder. By creating symbolic links from inside your application code folder to that adjacent folder you can better control the actual folder being bundled with your app when you upload it, making the entire dependency managmenet + python include procedure easier 
###Dependencies
amqplib 1.2.0 - bundled

I actually have no idea how to do this other than setting up the two folders amqp and ours at the same level in the folder hierarchy. 

Below is our current imports of pika.

#!/usr/bin/env python
"""
Defines an instance of the chimera message service, a layer of software that
uses AMQP to reliably deliver messages in store and forward mode but provides
a simple interface.

This program needs the following libraries installed to run:

pip install pika

"""

import pika
import chimera_log
import logging
import threading
import zlib
import os
import tempfile
import psutil
import time
from chimera_serializable_queue import SerializableQueue

logging.basicConfig()
logger=chimera_log.setup_custom_logger('chimera_message_service', 'chimera_message_service.log', logging.DEBUG)

# AMQP constants
DEFAULT_PRIORITY=0
PERSISTENT_DELIVER_MODE=2
DEFAULT_AMQP_PORT=5672
SSL_AMQP_PORT=5671
DEFAULT_SOCKET_TIMEOUT_S=1

class ChimeraMessageService():


Massimo Di Pierro

unread,
Jan 19, 2015, 5:51:08 PM1/19/15
to web...@googlegroups.com
 2 (in your app modules) is the right thing to do. Not sure why it does not work on GAE. What web2py version are you using? Can you try the latest?

Another option is put the libraries is web2py/site-packages which is added on sys.path by default. Please keep us updated about your progress. This has to work and is important.

Massimo
Reply all
Reply to author
Forward
0 new messages