Exemplo n.º 1
0
 def __init__(self, ep=None):
     RpcConnection.__init__(self, ep=ep)
     self.conn = None
     self.exitflag = False
     ep.impl = self
     self.mq_recv = ''
     RpcConnectionMQ_Collection.instance().add(self)
Exemplo n.º 2
0
	def __init__(self,ep=None):
		RpcConnection.__init__(self,ep=ep)
		self.conn = None
		self.exitflag = False
		ep.impl = self
		self.mq_recv =''
		RpcConnectionMQ_Collection.instance().add(self)
Exemplo n.º 3
0
	def __init__(self,ep):
		RpcConnection.__init__(self,ep=ep)
		self.conn = None
		self.exitflag = False
		ep.impl = self
		self.mq_recv='' #RPC调用返回消息回送的mq名称
		RpcConnectionEasyMQ_Collection.instance().add(self)
Exemplo n.º 4
0
 def __init__(self, ep):
     RpcConnection.__init__(self, ep=ep)
     self.conn = None
     self.exitflag = False
     ep.impl = self
     self.mq_recv = ''  #RPC调用返回消息回送的mq名称
     RpcConnectionEasyMQ_Collection.instance().add(self)
Exemplo n.º 5
0
    def sendMessage(self, m):

        if m.traits and m.traits.max_linger_time:
            value = m.extra.props.get(RpcMessageTraits.MAX_MSG_LINGER_TIME,
                                      '0')
            value = int(value)
            if not value:
                value += int(time.time())
                m.extra.setPropertyValue(RpcMessageTraits.MAX_MSG_LINGER_TIME,
                                         value)

            #app制定了超时接收时间,这里调整为绝对时间,以便接收端进行判别,选择接受还是丢弃

        if m.calltype & RpcMessage.RETURN:
            #--- Rpc的调用消息中包含接收消息的队列名称 ---
            mqname = m.callmsg.extra.props.get('__mq_return__')
            if mqname:
                mq = RpcConnectionMQ_Collection.instance().get(mqname)
                if mq:
                    mq.sendDetail(m)
                    return
            log_error('__mq_return__:<%s> is not in service mq-list!' % mqname)
            return False

        if self.mq_recv:
            m.extra.props['__mq_return__'] = self.mq_recv
        return RpcConnection.sendMessage(self, m)
Exemplo n.º 6
0
	def sendMessage(self,m):


		if m.traits and  m.traits.max_linger_time:
			value = m.extra.props.get(RpcMessageTraits.MAX_MSG_LINGER_TIME,'0')
			value = int(value)
			if not value:
				value +=  int(time.time())
				m.extra.setPropertyValue(RpcMessageTraits.MAX_MSG_LINGER_TIME, value )

			#app制定了超时接收时间,这里调整为绝对时间,以便接收端进行判别,选择接受还是丢弃

		if m.calltype & RpcMessage.RETURN:
			#--- Rpc的调用消息中包含接收消息的队列名称 ---
			mqname = m.callmsg.extra.props.get('__mq_return__')
			if mqname:
				mq = RpcConnectionMQ_Collection.instance().get(mqname)
				if mq:
					mq.sendDetail(m)
					return
			log_error('__mq_return__:<%s> is not in service mq-list!'%mqname)
			return False

		if self.mq_recv:
			m.extra.props['__mq_return__'] = self.mq_recv
		return RpcConnection.sendMessage(self,m)
Exemplo n.º 7
0
	def __init__(self,ep=None):
		import string

		RpcConnection.__init__(self,ep=ep)
		self.conn = None
		self.exitflag = False
		if ep :
			ep.impl = self
		self.mq_recv =''

		#parsing endpoint tuple
		fields = ep.addr.split(':')
		self.queue_type = fields.pop().strip().lower()
		uri = string.join(fields,':')
		self.address_read,self.address_write = map(string.strip,uri.split('%'))

		self.sock = None
		self.af = AF_NONE

		RpcConnectionMQ_Collection.instance().add(self)
Exemplo n.º 8
0
	def sendMessage(self,m):
		if m.calltype & RpcMessage.RETURN:
			#--- Rpc的调用消息中包含接收消息的队列名称 ---
			mqname = m.callmsg.extra.props.get('__mq_return__')
			if mqname:
				mq = RpcConnectionMQ_Collection.instance().get(mqname)
				if mq:
					mq.sendDetail(m)
					return
			log_error('__mq_return__:<%s> is not in service mq-list!'%mqname)
			return False

		#设置接收消息的队列名称
		if self.mq_recv:
			m.extra.props['__mq_return__'] = self.mq_recv
		return RpcConnection.sendMessage(self,m)
Exemplo n.º 9
0
    def sendMessage(self, m):
        if m.calltype & RpcMessage.RETURN:  #处理转发回送数据 包
            #--- 处理直接操作mq进行rpc调用的情形 ---
            mqname = m.callmsg.extra.props.get('__mq_return__')
            if mqname:
                mq = RpcConnectionEasyMQ_Collection.instance().get(mqname)
                if mq:
                    #del m.callmsg.extra.props['__mq_return__']
                    mq.sendDetail(m)
                    return
            # --- end ----
            log_error('__mq_return__:%s is not in service mq-list!' % mqname)
            return False

            #			type_,id = (m.call_id>>8)&0xff, m.call_id&0xff
            type_, id = (m.call_id >> 8) & 0x7f, m.call_id & 0xff
            #类型的最高位不用
            svc = RpcCommunicator.instance().getServiceDetail(type_)
            if not svc:
                log_error('not found service: src_type =%s' % type_)
                return False
            mqname = svc.pattern % id
            #			print mqname
            ep = RpcCommunicator.instance().currentServer().findEndPointByName(
                mqname)
            if not ep:
                log_error('ep <%s> undefined!' % mqname)
                return False
            return ep.impl.sendDetail(m)

#		server = RpcCommunicator.instance().currentServer()
#		if server.getPropertyValue('userid_check','false') == 'true':
#			if not self.userid: #未认证通过
#				return True
# calltype == CALL  携带 user_id到mq接收者
        if self.mq_recv:
            m.extra.props['__mq_return__'] = self.mq_recv
        #print 'mq sendmessage ..',m
        return RpcConnection.sendMessage(self, m)
Exemplo n.º 10
0
	def sendMessage(self,m):
		if m.calltype & RpcMessage.RETURN: #处理转发回送数据 包
			#--- 处理直接操作mq进行rpc调用的情形 ---
			mqname = m.callmsg.extra.props.get('__mq_return__')
			if mqname:
				mq = RpcConnectionEasyMQ_Collection.instance().get(mqname)
				if mq:
					#del m.callmsg.extra.props['__mq_return__']
					mq.sendDetail(m)
					return
			# --- end ----
			log_error('__mq_return__:%s is not in service mq-list!'%mqname)
			return False

#			type_,id = (m.call_id>>8)&0xff, m.call_id&0xff
			type_,id = (m.call_id>>8)&0x7f, m.call_id&0xff
			#类型的最高位不用
			svc = RpcCommunicator.instance().getServiceDetail(type_)
			if not svc:
				log_error('not found service: src_type =%s'%type_)
				return False
			mqname =svc.pattern%id
#			print mqname
			ep = RpcCommunicator.instance().currentServer().findEndPointByName(mqname)
			if not ep:
				log_error('ep <%s> undefined!'%mqname)
				return False
			return  ep.impl.sendDetail(m)

#		server = RpcCommunicator.instance().currentServer()
#		if server.getPropertyValue('userid_check','false') == 'true':
#			if not self.userid: #未认证通过
#				return True
		# calltype == CALL  携带 user_id到mq接收者
		if self.mq_recv:
			m.extra.props['__mq_return__'] = self.mq_recv
		#print 'mq sendmessage ..',m
		return RpcConnection.sendMessage(self,m)