Package flex.messaging.messages

Examples of flex.messaging.messages.CommandMessage


            flexClient.unregisterEndpointPushHandler(this, endpoint.getId());
        }

        // Push a disconnect command down to the client to suppress automatic reconnect.
        ArrayList list = new ArrayList(1);
        CommandMessage disconnect = new CommandMessage(CommandMessage.DISCONNECT_OPERATION);
        list.add(disconnect);
        pushMessages(list);

        // Invalidate associated subscriptions; this doesn't attempt to notify the client.
        // Any client subscriptions made over this endpoint will be automatically invalidated
View Full Code Here


            // or preceeded by other messages in the batch; the request-response loop must complete without waiting.
            // If the poll command is the only message in the batch it's ok to wait.
            // If it isn't ok to wait, tag the poll message with a header that short-circuits any potential poll-wait.
            if (inMessage instanceof CommandMessage)
            {
                CommandMessage command = (CommandMessage)inMessage;
                if ((command.getOperation() == CommandMessage.POLL_OPERATION) && (context.getRequestMessage().getBodyCount() != 1))
                    command.setHeader(CommandMessage.SUPPRESS_POLL_WAIT_HEADER, Boolean.TRUE);
            }           
           
            // If MPI is enabled update the MPI metrics on the object referred to by the context
            // and the messages
            if (context.isMPIenabled())           
View Full Code Here

        attemptingInvalidationClientNotification = notifyClient;
       
        // Build a subscription invalidation message and push to the client if it is still valid.
        if (notifyClient && flexClient != null && flexClient.isValid())
        {               
            CommandMessage msg = new CommandMessage();
            msg.setDestination(destination.getId());
            msg.setClientId(clientId);
            msg.setOperation(CommandMessage.SUBSCRIPTION_INVALIDATE_OPERATION);
            Set subscriberIds = new TreeSet();
            subscriberIds.add(clientId);
            try
            {
                ((MessageService)destination.getService()).pushMessageToClients(destination, subscriberIds, msg, false /* don't eval selector */);
            }
            catch (MessageException ignore) {}
        }       
       
        // Notify messageClientDestroyed listeners that we're being invalidated.
        if (destroyedListeners != null && !destroyedListeners.isEmpty())
        {
            for (Iterator iter = destroyedListeners.iterator(); iter.hasNext();)
            {
                ((MessageClientListener)iter.next()).messageClientDestroyed(this);               
            }
            destroyedListeners.clear();
        }

        // And generate unsubscribe messages for all of the MessageClient's subscriptions and
        // route them to the destination this MessageClient is subscribed to.
        // The reason we send a message to the service rather than just going straight to the SubscriptionManager
        // is that some adapters manage their own subscription state (i.e. JMS) in addition to us keeping track of
        // things with our SubscriptionManager.
        ArrayList unsubMessages = new ArrayList();
        synchronized (lock)
        {
            for (Iterator iter = subscriptions.iterator(); iter.hasNext();)
            {
                SubscriptionInfo subInfo = (SubscriptionInfo)iter.next();
                CommandMessage unsubMessage = new CommandMessage();
                unsubMessage.setDestination(destination.getId());
                unsubMessage.setClientId(clientId);
                unsubMessage.setOperation(CommandMessage.UNSUBSCRIBE_OPERATION);
                unsubMessage.setHeader(CommandMessage.SUBSCRIPTION_INVALIDATED_HEADER, Boolean.TRUE);
                unsubMessage.setHeader(CommandMessage.SELECTOR_HEADER, subInfo.selector);
                unsubMessage.setHeader(AsyncMessage.SUBTOPIC_HEADER_NAME, subInfo.subtopic);
                unsubMessages.add(unsubMessage);
            }
        }
        // Release the lock and send the unsub messages.
        for (Iterator iter = unsubMessages.iterator(); iter.hasNext();)
View Full Code Here

            message.setHeader(Message.VALIDATE_ENDPOINT_HEADER, Boolean.TRUE);
        message.setHeader(Message.ENDPOINT_HEADER, getId());       
               
        if (message instanceof CommandMessage)
        {
            CommandMessage command = (CommandMessage)message;
           
            // Apply channel endpoint level constraint; always allow login commands through.
            if (command.getOperation() != CommandMessage.LOGIN_OPERATION)
                checkSecurityConstraint(message);
           
            // Handle general (not Consumer specific) poll requests here.
            // We need to fetch all outbound messages for client subscriptions over this endpoint.
            // We identify these general poll messages by their operation and a null clientId.           
            int operation = command.getOperation();
            if (operation == CommandMessage.POLL_OPERATION && message.getClientId() == null)
            {
                verifyFlexClientSupport(command);
               
               
                FlexClient flexClient = FlexContext.getFlexClient();
                ack = handleFlexClientPollCommand(flexClient, command);                                                                                           
            }
            else if (operation == CommandMessage.DISCONNECT_OPERATION)
            {
                ack = handleChannelDisconnect(command);
            }
            else
            {
                // Block a subset of commands for legacy clients that need to be recompiled to
                // interop with a 2.5+ server.
                if (operation == CommandMessage.SUBSCRIBE_OPERATION || operation == CommandMessage.POLL_OPERATION)
                    verifyFlexClientSupport(command);
               
                ack = getMessageBroker().routeCommandToService((CommandMessage) message, this);

                // Look for client advertised features on initial connect.
                if (operation == CommandMessage.CLIENT_PING_OPERATION || operation == CommandMessage.LOGIN_OPERATION)
                {
                    Number clientVersion = (Number)command.getHeader(CommandMessage.MESSAGING_VERSION);
                    handleClientMessagingVersion(clientVersion);

                    // Also respond by advertising the messaging version on the
                    // acknowledgement.
                    ack.setHeader(CommandMessage.MESSAGING_VERSION, new Double(messagingVersion));
View Full Code Here

       
        // Generate a no-op poll response if necessary; prevents a single client from busy polling when the server
        // is doing wait()-based long-polls.
        if ((flushResult instanceof PollFlushResult) && ((PollFlushResult)flushResult).isClientProcessingSuppressed())
        {
            pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
            pollResponse.setHeader(CommandMessage.NO_OP_POLL_HEADER, Boolean.TRUE);
        }
       
        if (pollResponse == null)
        {
            List messagesToReturn = (flushResult != null) ? flushResult.getMessages() : null;
            if (messagesToReturn != null && !messagesToReturn.isEmpty())
            {
                pollResponse = new CommandMessage(CommandMessage.CLIENT_SYNC_OPERATION);
                pollResponse.setBody(messagesToReturn.toArray());
            }
            else
            {
                pollResponse = new AcknowledgeMessage();
View Full Code Here

TOP

Related Classes of flex.messaging.messages.CommandMessage

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.