Package flex.messaging

Examples of flex.messaging.MessageDestination


        </channels>
    </destination>
    */
    private MessageDestination createDestination(String id, MessageService messageService)
    {
        MessageDestination msgDest;
        msgDest = (MessageDestination)messageService.createDestination(id);

        // <network>
        NetworkSettings ns = new NetworkSettings();
        ns.setSubscriptionTimeoutMinutes(0);
        ThrottleSettings ts = new ThrottleSettings();
        ts.setInboundPolicy(ThrottleSettings.Policy.ERROR);
        ts.setIncomingClientFrequency(0);
        ts.setOutboundPolicy(ThrottleSettings.Policy.IGNORE);
        ts.setOutgoingClientFrequency(0);
        ns.setThrottleSettings(ts)
        //Uncomment the following for clustering test
        ns.setClusterId("default-tcp-cluster");
        msgDest.setNetworkSettings(ns);
       
        // <server>
        ServerSettings ss = new ServerSettings();
        ss.setMessageTTL(0);
        ss.setDurable(false);
        msgDest.setServerSettings(ss);
       
        //Use a channel that does not use the {server.name}:{server.port} tokens
        //msgDest.addChannel("qa-rtmp-cluster");       
        msgDest.addChannel("qa-amf-polling-cluster");
        //msgDest.addChannel("qa-http-polling-cluster");
       
        return msgDest;
    }
View Full Code Here


   
    // Create a new Message destination dynamically
    String serviceId = "message-service";
    MessageBroker broker = MessageBroker.getMessageBroker(null);
    MessageService service = (MessageService) broker.getService(serviceId);
    MessageDestination destination = (MessageDestination) service.createDestination(id);

    if (service.isStarted())
    {
      destination.start();
    }

    rooms.add(id);
   
  }
View Full Code Here

     * @param destination The destination of the adapter.
     */
    @Override
    public void setDestination(Destination destination)
    {
        MessageDestination dest = (MessageDestination)destination;
        super.setDestination(dest);
    }
View Full Code Here

         * 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

     * @param id The id of the <code>MessageDestination</code>.
     * @return The <code>Destination</code> instanced created.
     */
    public Destination createDestination(String id)
    {
        MessageDestination destination = new MessageDestination();
        destination.setId(id);
        destination.setManaged(isManaged());
        destination.setService(this);

        return destination;
    }
View Full Code Here

     *
     * @param destination The <code>Destination</code> instance to be added.
     */
    public void addDestination(Destination destination)
    {
        MessageDestination messageDestination = (MessageDestination)destination;
        super.addDestination(messageDestination);
    }
View Full Code Here

    {
        Object result = null;

        incrementMessageCount(false, message);

        MessageDestination dest = (MessageDestination) getDestination(message);

        // Throttle the inbound message - this also attempts to prevent duplicate
        // messages sent by a client.
        ThrottleResult throttleResult;
        if (throttle)
            throttleResult = dest.getThrottleManager().throttleIncomingMessage(message);
        else
            throttleResult = new ThrottleResult(ThrottleResult.RESULT_OK);

        int throttleResultCode = throttleResult.getResultCode();
        MessageException me = throttleResult.getException();
        if (throttleResultCode == ThrottleResult.RESULT_ERROR)
        {
            throw me;
        }
        else if (throttleResultCode == ThrottleResult.RESULT_IGNORE)
        {
            if (Log.isDebug())
                Log.getLogger(LOG_CATEGORY).debug(me.getMessage(), me);
        }
        else
        {
            // Block any sent messages that have a subtopic header containing
            // wildcards - wildcards are only supported in subscribe/unsubscribe
            // commands (see serviceCommand() and manageSubscriptions()).

            Object subtopicObj = message.getHeader(AsyncMessage.SUBTOPIC_HEADER_NAME);

            if (subtopicObj instanceof Object[])
                subtopicObj = Arrays.asList((Object[])subtopicObj);

            if (subtopicObj instanceof String)
            {
                String subtopicString = (String) subtopicObj;
                testProducerSubtopic(dest, subtopicString);
            }
            else if (subtopicObj instanceof List)
            {
                List subtopicList = (List) subtopicObj;

                for (int i = 0; i < subtopicList.size(); i++)
                    testProducerSubtopic(dest, (String) subtopicList.get(i));
            }

            // override TTL if there was one specifically configured for this destination
            ServerSettings destServerSettings = dest.getServerSettings();
            if (destServerSettings.getMessageTTL() >= 0)
                message.setTimeToLive(destServerSettings.getMessageTTL());

            long start = 0;
            if (Log.isDebug())
                start = System.currentTimeMillis();

            // Give MessagingAdapter a chance to block the send.
            ServiceAdapter adapter = dest.getAdapter();
            if (adapter instanceof MessagingAdapter)
                ((MessagingAdapter)adapter).getSecurityConstraintManager().assertSendAuthorization();

            MessagePerformanceUtils.markServerPreAdapterTime(message);
            result = adapter.invoke(message);
View Full Code Here

    public void serviceMessageFromAdapter(Message message, boolean sendToAllSubscribers)
    {
        // Update management metrics.
        if (isManaged())
        {
            MessageDestination destination = (MessageDestination)getDestination(message.getDestination());
            if (destination != null && destination.isManaged())
            {
                MessageDestinationControl destinationControl = (MessageDestinationControl)destination.getControl();
                if (destinationControl != null) // Should not happen but just in case.
                    destinationControl.incrementServiceMessageFromAdapterCount();
            }
        }
View Full Code Here

     * @param evalSelector <code>true</code> to evaluate each remote subscriber's selector before pushing
     *        the message to them; <code>false</code> to skip selector evaluation.
     */
    public void sendPushMessageFromPeer(Message message, boolean evalSelector)
    {
        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);

View Full Code Here

     * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing
     *        the message to them; <code>false</code> to skip selector evaluation.
     */
    public void pushMessageToClients(Message message, boolean evalSelector)
    {
        MessageDestination destination = (MessageDestination)getDestination(message);
        SubscriptionManager subscriptionManager = destination.getSubscriptionManager();
        Set subscriberIds = subscriptionManager.getSubscriberIds(message, evalSelector);

        if (Log.isDebug())
            Log.getLogger(LOG_CATEGORY).debug("Sending message: " + message + StringUtils.NEWLINE + "    to subscribed clientIds: " + subscriberIds);

View Full Code Here

TOP

Related Classes of flex.messaging.MessageDestination

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.