Package flex.messaging.cluster

Examples of flex.messaging.cluster.ClusterManager


    //--------------------------------------------------------------------------

    public void start()
    {
        String serviceType = getClass().getName();
        ClusterManager clm = getMessageBroker().getClusterManager();

        super.start();

        /*
         * For any destinations which are not using broadcast mode,
         * we need to init the remote subscriptions.  First we send out
         * the requestSubscription messages, then we wait for the sendSubscriptions
         * messages to come in.
         */
        for (Iterator it = destinations.keySet().iterator(); it.hasNext(); )
        {
            String destName = (String) it.next();
            MessageDestination dest = (MessageDestination) getDestination(destName);
            if (!dest.getServerSettings().isBroadcastRoutingMode() && dest.isClustered())
                initRemoteSubscriptions(destName);
        }

        /* Now go through and wait for the response to these messages... */
        for (Iterator it = destinations.keySet().iterator(); it.hasNext(); )
        {
            String destName = (String) it.next();
            MessageDestination dest = (MessageDestination) getDestination(destName);
            if (!dest.getServerSettings().isBroadcastRoutingMode() && dest.isClustered())
            {
                List members = clm.getClusterMemberAddresses(serviceType, destName);
                for (int i = 0; i < members.size(); i++)
                {
                    Object addr = members.get(i);
                    if (!clm.getLocalAddress(serviceType, destName).equals(addr))
                    {
                        RemoteSubscriptionManager subMgr = dest.getRemoteSubscriptionManager();
                        subMgr.waitForSubscriptions(addr);
                    }
                }
View Full Code Here


    {
        MessageDestination destination = (MessageDestination) getDestination(message);

           if (destination.isClustered())
        {
            ClusterManager clm = getMessageBroker().getClusterManager();
            if (destination.getServerSettings().isBroadcastRoutingMode())
            {
                if (Log.isDebug())
                    Log.getLogger(LOG_CATEGORY).debug("Broadcasting message to peer servers: " + message + " evalSelector: " + evalSelector);
                // tell the message service on other nodes to push the message
                clm.invokeServiceOperation(getClass().getName(), message.getDestination(),
                        "pushMessageFromPeer", new Object[] { message, Boolean.valueOf(evalSelector) });
            }
            else
            {
                RemoteSubscriptionManager mgr = destination.getRemoteSubscriptionManager();
                Set serverAddresses = mgr.getSubscriberIds(message, evalSelector);

                if (Log.isDebug())
                    Log.getLogger(LOG_CATEGORY).debug("Sending message to peer servers: " + serverAddresses + StringUtils.NEWLINE + " message: " + message + StringUtils.NEWLINE + " evalSelector: " + evalSelector);

                for (Iterator it = serverAddresses.iterator(); it.hasNext(); )
                {
                    Object remoteAddress = it.next();

                    clm.invokePeerToPeerOperation(getClass().getName(), message.getDestination(),
                            "pushMessageFromPeerToPeer", new Object[] { message, Boolean.valueOf(evalSelector)}, remoteAddress);
                }
            }
        }
    }
View Full Code Here

    /**
     * Issue messages to request the remote subscription table from each server in the cluster (except this one).
     */
    public void initRemoteSubscriptions(String destinationId)
    {
        ClusterManager clm = getMessageBroker().getClusterManager();
        String serviceType = getClass().getName();
        MessageDestination dest = (MessageDestination) getDestination(destinationId);

        Cluster cluster = clm.getCluster(serviceType, destinationId);
        if (cluster != null)
            cluster.addRemoveNodeListener(dest.getRemoteSubscriptionManager());

        List members = clm.getClusterMemberAddresses(serviceType, destinationId);
        for (int i = 0; i < members.size(); i++)
        {
            Object addr = members.get(i);
            if (!clm.getLocalAddress(serviceType, destinationId).equals(addr))
                requestSubscriptions(destinationId, addr);
        }

    }
View Full Code Here

     *
     * @exclude
     */
    public void requestSubscriptions(String destinationId, Object remoteAddress)
    {
        ClusterManager clm = getMessageBroker().getClusterManager();
        clm.invokePeerToPeerOperation(getClass().getName(), destinationId,
                "sendSubscriptions", new Object[] { destinationId }, remoteAddress);
    }
View Full Code Here

            if (destination instanceof MessageDestination)
                subscriptions = ((MessageDestination) destination).getSubscriptionManager().getSubscriptionState();
            else
                subscriptions = null;
            ClusterManager clm = getMessageBroker().getClusterManager();
            clm.invokePeerToPeerOperation(getClass().getName(), destinationId,
                    "receiveSubscriptions", new Object[] { destinationId, subscriptions }, remoteAddress);
        }
        finally
        {
            /* ... And here */
 
View Full Code Here

     *
     * @exclude
     */
    public void sendSubscribeFromPeer(String destinationId, Boolean subscribe, String selector, String subtopic)
    {
        ClusterManager clm = getMessageBroker().getClusterManager();

        String serviceType = getClass().getName();

        clm.invokeServiceOperation(serviceType, destinationId,
                        "subscribeFromPeer", new Object[] { destinationId, subscribe, selector, subtopic, clm.getLocalAddress(serviceType, destinationId)});
    }
View Full Code Here

        }
    }

    private void prepareClusters(MessageBroker broker)
    {
        ClusterManager clusterManager = broker.getClusterManager();
        for (Iterator iter=clusterSettings.keySet().iterator(); iter.hasNext(); )
        {
            String clusterId = (String) iter.next();
            ClusterSettings cs = (ClusterSettings) clusterSettings.get(clusterId);
            clusterManager.prepareCluster(cs);
        }
    }
View Full Code Here

        {
            commandResult = Boolean.TRUE;
        }
        else if (message.getOperation() == CommandMessage.CLUSTER_REQUEST_OPERATION)
        {
            ClusterManager clusterManager = getMessageBroker().getClusterManager();
            String serviceType = getClass().getName();
            String destinationName = message.getDestination();
            if (clusterManager.isDestinationClustered(serviceType, destinationName))
            {
                commandResult = clusterManager.getEndpointsForDestination(serviceType, destinationName);
            }
            else
            {
                // client should never send this message if its local
                // config declares the destination is not clustered
View Full Code Here

            securityConstraint = broker.getSecurityConstraint(securityConstraintRef);
            // No need to throw an error as MessageBroker automatically throws
            // an error if no such constraint exists
        }

        ClusterManager cm = broker.getClusterManager();

        // Set clustering if needed
        if (getNetworkSettings().getClusterId() != null || cm.getDefaultClusterId() != null)
        {
            cm.clusterDestination(this);
        }
    }
View Full Code Here

    public boolean isBackendShared()
    {
        if (!isStarted())
            return false;

        ClusterManager clm = getService().getMessageBroker().getClusterManager();
        boolean backendShared = clm.isBackendShared(getService().getClass().getName(), getId());
        return backendShared;
    }
View Full Code Here

TOP

Related Classes of flex.messaging.cluster.ClusterManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.