Exemplo n.º 1
0
 def _on_message(self, msg, args):
     """ Invoked for each message taken off a ZMQ socket.
     """
     with self.channel_lock:
         params = {}
         params['action'] = CHANNEL.ZMQ_MESSAGE_RECEIVED
         params['service'] = self.channel.service
         params['rid'] = new_rid()
         params['payload'] = msg
         
         self.broker_client.send_json(params, msg_type=MESSAGE_TYPE.TO_PARALLEL_PULL)
Exemplo n.º 2
0
 def _on_message(self, method_frame, header_frame, body):
     """ A callback to be invoked by ConsumingConnection on each new AMQP message.
     """
     with self.def_amqp_lock:
         with self.channel_amqp_lock:
             params = {}
             params['action'] = CHANNEL.AMQP_MESSAGE_RECEIVED
             params['service'] = self.channel_amqp.service
             params['rid'] = new_rid()
             params['payload'] = body
             
             self.broker_client.send_json(params, msg_type=MESSAGE_TYPE.TO_PARALLEL_PULL)
Exemplo n.º 3
0
 def _on_job_execution(self, name, service, extra):
     """ Invoked by the underlying APScheduler when a job is executed. Sends
     the actual execution request to the broker so it can be picked up by
     one of the parallel server's broker clients.
     """
     msg = {'action': SCHEDULER.JOB_EXECUTED, 'name':name, 'service': service, 'payload':extra,
            'rid':new_rid()}
     self.singleton.broker_client.send_json(msg)
     
     if logger.isEnabledFor(logging.DEBUG):
         msg = 'Sent a job execution request, name [{0}], service [{1}], extra [{2}]'.format(
             name, service, extra)
         logger.debug(msg)
Exemplo n.º 4
0
 def _on_message(self, msg):
     """ Invoked for each message taken off a WebSphere MQ queue.
     """
     with self.def_lock:
         with self.channel_lock:
             params = {}
             params['action'] = CHANNEL.JMS_WMQ_MESSAGE_RECEIVED
             params['service'] = self.channel.service
             params['rid'] = new_rid()
             params['payload'] = msg.text
             
             for attr in MESSAGE_ATTRS:
                 params[attr] = getattr(msg, attr, None)
             
             self.broker_client.send_json(params, msg_type=MESSAGE_TYPE.TO_PARALLEL_PULL)
Exemplo n.º 5
0
    def executeRequest(self, task, thread_ctx):
        """ Handles incoming HTTP requests. Each request is being handled by one
        of the threads created in ParallelServer.run_forever method.
        """
        rid = new_rid()
        response = str(rid)
        
        try:
            # SOAP or plain HTTP.
            response = thread_ctx.store.request_handler.handle(rid, task, thread_ctx)

        # Any exception at this point must be our fault.
        except Exception, e:
            tb = format_exc(e)
            task.setResponseStatus(INTERNAL_SERVER_ERROR, responses[INTERNAL_SERVER_ERROR])
            error_msg = '[{0}] Exception caught [{1}]'.format(rid, tb)
            logger.error(error_msg)
            
            response = error_msg
            task.response_headers['Content-Type'] = 'text/plain'