Implement L{IMessageRouter.routeMessage} by locating a shared item
        which provides L{IMessageReceiver}, identified by L{target} in this
        L{MessageQueue}'s L{Store}, as shared to the specified C{sender}, then
        invoke its L{messageReceived} method.  Then, take the results of that
        L{messageReceived} invocation and deliver them as an answer to the
        object specified by L{sender}.

        If any of these steps fail such that no
        L{IMessageReceiver.messageReceived} method may be invoked, generate a
        L{DELIVERY_ERROR} response instead.

def routeMessage(self, sender, target, value, messageID):
        """
        Implement L{IMessageRouter.routeMessage} by locating a shared item
        which provides L{IMessageReceiver}, identified by L{target} in this
        L{MessageQueue}'s L{Store}, as shared to the specified C{sender}, then
        invoke its L{messageReceived} method.  Then, take the results of that
        L{messageReceived} invocation and deliver them as an answer to the
        object specified by L{sender}.

        If any of these steps fail such that no
        L{IMessageReceiver.messageReceived} method may be invoked, generate a
        L{DELIVERY_ERROR} response instead.
        """
        avatarName = sender.localpart + u"@" + sender.domain
        # Look for the sender.
        answer = self.store.findUnique(
            _AlreadyAnswered,
            AND(_AlreadyAnswered.originalSender == sender,
                _AlreadyAnswered.messageID == messageID),
            default=None)
        if answer is None:
            role = getPrimaryRole(self.store, avatarName)
            try:
                receiver = role.getShare(target.shareID)
            except NoSuchShare:
                response = Value(DELIVERY_ERROR,  ERROR_NO_SHARE)
            else:
                try:
                    def txn():
                        output = receiver.messageReceived(value, sender,
                                                          target)
                        if not isinstance(output, Value):
                            raise TypeError("%r returned non-Value %r" %
                                            (receiver, output))
                        return output
                    response = self.store.transact(txn)
                except RevertAndRespond, rar:
                    response = rar.value
                except:
                    log.err(Failure(),
                            "An error occurred during inter-store "
                            "message delivery.")
                    response = Value(DELIVERY_ERROR, ERROR_REMOTE_EXCEPTION)
            answer = _AlreadyAnswered.create(store=self.store,
                                             originalSender=sender,
                                             originalTarget=target,
                                             messageID=messageID,
                                             value=response)
        self._deliverAnswer(answer)
        self._scheduleMePlease()