cometd-java/cometd-java-oort/src/main/java/org/cometd/oort/OortService.java
/**
     * <p>Subclasses must call this method to forward the action to the owner node.</p>
     * <p>If the {@code targetOortURL} is {@code null}, then the action is broadcast to all nodes.
     * Nodes that receive an action request that they can't fullfill because they don't own the
     * entity the action should be applied to must return {@link Result#ignore(Object)}.</p>
     *
     * @param targetOortURL the owner node Oort URL, or null to broadcast the action to all nodes
     * @param parameter     the action parameter that will be passed to {@link #onForward(Request)}
     * @param context       the opaque context passed to {@link #onForwardSucceeded(Object, Object)}
     * @return whether the forward succeeded
     */
Subclasses must call this method to forward the action to the owner node.
If the  targetOortURL is  null, then the action is broadcast to all nodes.
Nodes that receive an action request that they can't fullfill because they don't own the
entity the action should be applied to must return  Result#ignore(Object).

@param targetOortURL the owner node Oort URL, or null to broadcast the action to all nodes
@param parameter     the action parameter that will be passed to  #onForward(Request)
@param context       the opaque context passed to  #onForwardSucceeded(Object, Object)
@return whether the forward succeeded
Subclasses must call this method to forward the action to the owner node . If the targetOortURL is null then the action is broadcast to all nodes . Nodes that receive an action request that they can ' t fullfill because they don ' t own the entity the action should be applied to must return Result#ignore ( Object ) . @param targetOortURL the owner node Oort URL or null to broadcast the action to all nodes @param parameter the action parameter that will be passed to #onForward ( Request ) @param context the opaque context passed to #onForwardSucceeded ( Object Object ) @return whether the forward succeeded
protected boolean forward(String targetOortURL, Object parameter, C context) {
        Map<String, Object> ctx = new HashMap<>(4);
        long contextId = contextIds.incrementAndGet();
        ctx.put(ID_FIELD, contextId);
        ctx.put(CONTEXT_FIELD, context);
        callbacks.put(contextId, ctx);
        Map<String, Object> data = new HashMap<>(3);
        data.put(ID_FIELD, contextId);
        data.put(PARAMETER_FIELD, parameter);
        String localOortURL = getOort().getURL();
        data.put(OORT_URL_FIELD, localOortURL);
        if (targetOortURL == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Broadcasting action: {}", data);
            }
            startTimeout(ctx);
            oort.getBayeuxServer().getChannel(broadcastChannelName).publish(getLocalSession(), data, Promise.noop());
            return true;
        } else {
            if (localOortURL.equals(targetOortURL)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Forwarding action locally ({}): {}", localOortURL, data);
                }
                startTimeout(ctx);
                onForwardMessage(data, false);
                return true;
            } else {
                OortComet comet = getOort().getComet(targetOortURL);
                if (comet != null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Forwarding action from {} to {}: {}", localOortURL, targetOortURL, data);
                    }
                    startTimeout(ctx);
                    comet.getChannel(forwardChannelName).publish(data);
                    return true;
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Could not forward action from {} to {}: {}", localOortURL, targetOortURL, data);
                    }
                    return false;
                }
            }
        }
    }
protected boolean forward ( String targetOortURL , Object parameter , C context ) { Map < String , Object > ctx = new HashMap < > ( 4 ) ; long contextId = contextIds . incrementAndGet ( ) ; ctx . put ( ID_FIELD , contextId ) ; ctx . put ( CONTEXT_FIELD , context ) ; callbacks . put ( contextId , ctx ) ; Map < String , Object > data = new HashMap < > ( 3 ) ; data . put ( ID_FIELD , contextId ) ; data . put ( PARAMETER_FIELD , parameter ) ; String localOortURL = getOort ( ) . getURL ( ) ; data . put ( OORT_URL_FIELD , localOortURL ) ; if ( targetOortURL == null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Broadcasting action: {}" , data ) ; } startTimeout ( ctx ) ; oort . getBayeuxServer ( ) . getChannel ( broadcastChannelName ) . publish ( getLocalSession ( ) , data , Promise . noop ( ) ) ; return true ; } else { if ( localOortURL . equals ( targetOortURL ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Forwarding action locally ({}): {}" , localOortURL , data ) ; } startTimeout ( ctx ) ; onForwardMessage ( data , false ) ; return true ; } else { OortComet comet = getOort ( ) . getComet ( targetOortURL ) ; if ( comet != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Forwarding action from {} to {}: {}" , localOortURL , targetOortURL , data ) ; } startTimeout ( ctx ) ; comet . getChannel ( forwardChannelName ) . publish ( data ) ; return true ; } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Could not forward action from {} to {}: {}" , localOortURL , targetOortURL , data ) ; } return false ; } } } }
<p>Subclasses must call this method to forward the action to the owner node.</p>
 <p>If the {@code targetOortURL} is {@code null}, then the action is broadcast to all nodes.
<p > Subclasses must call this method to forward the action to the owner node . < / p > <p > If the { @code targetOortURL } is { @code null } then the action is broadcast to all nodes .
// Application does not know where the entity is, broadcast // Local case // Remote case