Processes ViewChangeDone messages. Once n-f messages have been
        received, decides on a primary for specific replica.

        :param msg: ViewChangeDone message
        :param sender: the name of the node from which this message was sent
491586
def process_vchd_msg(self, msg: ViewChangeDone, sender: str) -> bool:
        
        logger.info("{}'s primary selector started processing of ViewChangeDone msg from {} : {}".
                    format(self.name, sender, msg))
        view_no = msg.viewNo
        if self.view_no != view_no:
            self.provider.discard(msg, '{} got Primary from {} for view no {} '
                                       'whereas current view no is {}'.
                                  format(self, sender, view_no, self.view_no),
                                  logMethod=logger.info)
            return False

        new_primary_name = msg.name
        if new_primary_name == self.previous_master_primary:
            self.provider.discard(msg, '{} got Primary from {} for {} who was primary of '
                                       'master in previous view too'.
                                  format(self, sender, new_primary_name),
                                  logMethod=logger.info)
            return False

        # Since a node can send ViewChangeDone more than one time
        self._on_verified_view_change_done_msg(msg, sender)
        # TODO why do we check that after the message tracking
        if self.provider.has_primary():
            self.provider.discard(msg, "it already decided primary which is {}".
                                  format(self.provider.current_primary_name()), logger.info)
            return False

        self._start_selection()
331053
function postMessageToNode(messageId) {
        var msg = {
            fn: messageId,
            args: getFunctionArgs(arguments),
            requester: domainID
        };
        updateDomain.exec('data', msg);
    }
366445
async def ack(self, msg):
        
        ack_proto = protocol.Ack()
        ack_proto.subject = msg.proto.subject
        ack_proto.sequence = msg.proto.sequence
        await self._nc.publish(msg.sub.ack_inbox, ack_proto.SerializeToString())
53057
def isMsgFromPrimary(self, msg, sender: str) -> bool:
        
        if self.isMsgForCurrentView(msg):
            return self.primaryName == sender
        try:
            return self.primaryNames[msg.viewNo] == sender
        except KeyError:
            return False
390297
def messageReceived(self, message):
        
        if len(message) == 2:
            # compatibility receiving of tag as first part
            # of multi-part message
            self.gotMessage(message[1], message[0])
        else:
            self.gotMessage(*reversed(message[0].split(b'\0', 1)))
1278584
@Override
    public void onMessage(StreamMessage received)
    {
        if (this.reloadConfig && this.watcher != null)
        {
            Map<String, Object> reloadedConfig = null;

            try
            {
                reloadedConfig = this.watcher.readIfUpdated();
            }
            catch (IOException ex)
            {
                String logFormat = "Config file reload failed. Skip reload config.";
                logger.warn(logFormat, ex);
            }

            if (reloadedConfig != null)
            {
                onUpdate(reloadedConfig);
            }
        }

        this.executingKeyHistory = received.getHeader().getHistory();
        this.responsed = false;

        // Execute message processing.
        // This class not handles exceptions.
        // Because if throws exception, this class not need ack.
        try
        {
            onExecute(received);
        }
        finally
        {
            clearExecuteStatus();
        }

        // If not responsed, auto ack
        if (this.responsed == false)
        {
            super.ack();
        }
    }
401044
public void updateMessageListForHandler(String msgIds, String handlerId) {
        if (msgIds == null) {
            return; // Should never happen, but avoid NPEs
        }

        String[] msgStr = msgIds.split(",");
        ArrayList<String> newMsgList = new ArrayList<String>(Arrays.asList(msgStr));
        newMsgList.remove(""); // Ignore blank value

        // Get the list of existing handlers mapped to this message ID.
        ArrayList<String> prevMsgList = previousHandlerMessageMap.get(handlerId);
        {
            if (prevMsgList == null) {
                prevMsgList = new ArrayList<String>();
            }
        }

        if (prevMsgList.equals(newMsgList)) {
            return; // No change = nothing to do here, skip issuing message
        }

        getMessageRouter(); // Ensure router is not null

        // Check for new messages and add them to the list for the handler
        ArrayList<String> addedMsgs = new ArrayList<String>(newMsgList);
        addedMsgs.removeAll(prevMsgList);

        for (String msgId : addedMsgs) {
            msgRouter.addMsgToLogHandler(msgId, handlerId);
        }

        // Check for removed messages and remove them from the list for the handler
        ArrayList<String> removedMsgs = new ArrayList<String>(prevMsgList);
        removedMsgs.removeAll(newMsgList);

        for (String msgId : removedMsgs) {
            msgRouter.removeMsgFromLogHandler(msgId, handlerId);
        }

        // Save the new map for the next config change
        previousHandlerMessageMap.put(handlerId, newMsgList);

        // Notify that there was a change in this handler's messages
        String setOfIds = "";
        for (String msg : newMsgList) {
            if (!setOfIds.equals("")) {
                setOfIds = setOfIds.concat(" ");
            }
            setOfIds = setOfIds.concat(msg);
        }
        Tr.info(tc, "MSG_ROUTER_UPDATED", new Object[] { handlerId, setOfIds });
    }
1156136
def psh_fire_msg_action_if_new(sender, instance, created, **kwargs):
    
    if created:
        from message_sender.tasks import send_message

        send_message.apply_async(kwargs={"message_id": str(instance.id)})
1301572
def _messageFromSender(self, sender, messageID):
        
        return self.store.findUnique(
            _QueuedMessage,
            AND(_QueuedMessage.senderUsername == sender.localpart,
                _QueuedMessage.senderDomain == sender.domain,
                _QueuedMessage.messageID == messageID),
            default=None)
630874
def serviceViewChangerOutBox(self, limit: int = None) -> int:
        
        msgCount = 0
        while self.view_changer.outBox and (not limit or msgCount < limit):
            msgCount += 1
            msg = self.view_changer.outBox.popleft()
            if isinstance(msg, (InstanceChange, ViewChangeDone)):
                self.send(msg)
            else:
                logger.error("Received msg {} and don't know how to handle it".
                             format(msg))
        return msgCount
255634
def view_change_started(self, viewNo: int):
        
        if viewNo <= self.viewNo:
            logger.warning("{}Provided view no {} is not greater"
                           " than the current view no {}"
                           .format(VIEW_CHANGE_PREFIX, viewNo, self.viewNo))
            return False
        self.previous_master_primary = self.node.master_primary_name
        for replica in self.replicas.values():
            replica.primaryName = None
        return True
283600
async def send(self, msg: Message):
        
        if not msg.sender:
            msg.sender = str(self.agent.jid)
            logger.debug(f"Adding agent's jid as sender to message: {msg}")
        await self.agent.container.send(msg, self)
        msg.sent = True
        self.agent.traces.append(msg, category=str(self))
1302592
def process_message(message)
      logger.info("Calling event #{message.message_type} in the channel #{message.channel_type}")
      @listener_channels[message.channel_type.to_sym].message(message.message_type.to_sym, message)
    end
359254
def observer_update(self, message):
        """"""
        # Demultiplex observer update into multiple messages.
        for action in ('added', 'changed', 'removed'):
            for item in message[action]:
                self.send_json(
                    {
                        'msg': action,
                        'observer': message['observer'],
                        'primary_key': message['primary_key'],
                        'order': item['order'],
                        'item': item['data'],
                    }
                )
457687
function(sender, evt)
	{
		var changes = evt.getProperty('edit').changes;
		graph.setSelectionCells(graph.getSelectionCellsForChanges(changes));
	}
500211
def post_change_receiver(self, instance: Model, action: Action, **kwargs):
        
        try:
            old_group_names = instance.__instance_groups.observers[self]
        except (ValueError, KeyError):
            old_group_names = set()

        if action == Action.DELETE:
            new_group_names = set()
        else:
            new_group_names = set(self.group_names(instance))

        # if post delete, new_group_names should be []

        # Django DDP had used the ordering of DELETE, UPDATE then CREATE for good reasons.
        self.send_messages(
            instance,
            old_group_names - new_group_names,
            Action.DELETE,
            **kwargs
        )
        # the object has been updated so that its groups are not the same.
        self.send_messages(
            instance,
            old_group_names & new_group_names,
            Action.UPDATE,
            **kwargs
        )

        #
        self.send_messages(
            instance,
            new_group_names - old_group_names,
            Action.CREATE,
            **kwargs
        )
408348
async def _process_msg(self, sub):
        
        while True:
            try:
                raw_msg = await sub._msgs_queue.get()
                msg = Msg()
                msg_proto = protocol.MsgProto()
                msg_proto.ParseFromString(raw_msg.data)
                msg.proto = msg_proto
                msg.sub = sub

                # Yield the message to the subscription callback.
                await sub.cb(msg)

                if not sub.manual_acks:
                    # Process auto-ack if not done manually in the callback,
                    # by publishing into the ack inbox from the subscription.
                    msg_ack = protocol.Ack()
                    msg_ack.subject = msg.proto.subject
                    msg_ack.sequence = msg.proto.sequence
                    await self._nc.publish(sub.ack_inbox, msg_ack.SerializeToString())
            except asyncio.CancelledError:
                break
            except Exception as ex:
                if sub.error_cb:
                    try:
                        await sub.error_cb(ex)
                    except:
                        logger.exception(
                            "Exception in error callback for subscription to '%s'",
                            sub.subject
                        )
                continue