def sendMessages(self, data_structs, connectionId=None): """ Sends a list of messages. Args: data_structs: Sequence of messages to send. connectionId: Target connection (default: all). Raises: ValueError: If connectionId is given and does not match any connection. """ outgoing = [] msgid = None for msg in data_structs: msgid = msg.getId() outgoing.append( CF.DataType(id=msg.getId(), value=struct_to_any(msg))) outmsg = props_to_any(outgoing) try: # try to push entire message set self._push(outmsg, connectionId) except CORBA.MARSHAL: if len(data_structs) == 1: self._port_log.warn("Could not deliver the message id=" + str(msgid) + ". Maximum message size exceeded") else: self._port_log.warn( "Could not deliver the message. Maximum message size exceeded, trying individually" ) # try resending individually for msg in data_structs: outm = props_to_any([ CF.DataType(id=msg.getId(), value=struct_to_any(msg)) ]) try: self._push(outm, connectionId) except CORBA.MARSHAL: self._port_log.warn( "Could not deliver the message id=" + str(msg.getId()) + ". Maximum message size exceeded") break except: print "WARNING: Unable to send data to", connection
def sendMessages(self, data_structs): self.portInterfaceAccess.acquire() try: outgoing = [] for msg in data_structs: outgoing.append(CF.DataType(id=msg.getId(),value=struct_to_any(msg))) outmsg = props_to_any(outgoing) except: self.portInterfaceAccess.release() raise for connection in self._connections: try: self._connections[connection]['proxy_consumer'].push(outmsg) except: print "WARNING: Unable to send data to",connection self.portInterfaceAccess.release()
def sendMessage(self, data_struct): self.portInterfaceAccess.acquire() if not isinstance(data_struct, CORBA.Any): try: outgoing = [CF.DataType(id=data_struct.getId(),value=struct_to_any(data_struct))] outmsg = props_to_any(outgoing) except: self.portInterfaceAccess.release() raise else: outmsg = data_struct for connection in self._connections: try: self._connections[connection]['proxy_consumer'].push(outmsg) except: print "WARNING: Unable to send data to",connection self.portInterfaceAccess.release()
def sendMessage(self, data_struct, connectionId=None): """ Sends a single message. Args: data_struct: Message structure or CORBA.Any to send. connectionId: Target connection (default: all). Raises: ValueError: If connectionId is given and does not match any connection. """ if not isinstance(data_struct, CORBA.Any): outgoing = [CF.DataType(id=data_struct.getId(),value=struct_to_any(data_struct))] outmsg = props_to_any(outgoing) else: outmsg = data_struct self.push(outmsg, connectionId)
def process(self): self.mymessage.EnterMessageHere = "Congrats on your new message!" self.port_message_out.sendMessage(self.mymessage) # This code only handles 1 connection to the port if len(self.port_eventChannel_out.getConnectionIds()) != 0: connectionID = self.port_eventChannel_out.getConnectionIds()[0] if self.consumer is None: self.consumer = self.port_eventChannel_out.for_suppliers(connectionID).obtain_push_consumer() self.consumer.connect_push_supplier(self.Supplier_i()._this()) dt = CF.DataType(id=self.mymessage.getId(), value=properties.struct_to_any(self.mymessage)) anyProps = properties.props_to_any([dt]) try: self.consumer.push(anyProps) except: try: self.consumer.disconnect_push_consumer() except: pass self.consumer = None time.sleep(2) return NOOP