Package flex.messaging

Examples of flex.messaging.MessageException


                        }

                        if (!context.ignorePropertyErrors)
                        {
                            // Cannot send a null Map key for type {0}.
                            MessageException ex = new MessageException();
                            ex.setMessage(NULL_KEY_ERROR, new Object[] {map.getClass().getName()});
                            throw ex;
                        }
                    }
                }
            }
View Full Code Here


                inMessage = (Message)data;
            }
            else
            {
                inMessage = null;
                throw new MessageException("Request was not of type flex.messaging.messages.Message");
            }
   
            try
            {
                // Lookup or create the correct FlexClient.
                endpoint.setupFlexClient(inMessage);
   
                // Assign a clientId if necessary.
                // We don't need to assign clientIds to general poll requests.
                if (inMessage.getClientId() == null &&
                    (!(inMessage instanceof CommandMessage) || ((CommandMessage)inMessage).getOperation() != CommandMessage.POLL_OPERATION))
                {
                    Object clientId = UUIDUtils.createUUID();
                    inMessage.setClientId(clientId);
                }
               
                // Messages received via the AMF channel can be batched (by NetConnection on the client) and
                // we must not put the handler thread into a poll-wait state if a poll command message is followed by
                // or preceded 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())           
                    MessagePerformanceUtils.setupMPII(context, inMessage);
   
                // Service the message.
                responseMessage = endpoint.serviceMessage(inMessage);
   
                // Suspend the chain if we get back a 'poison-pill' message header.
                if (responseMessage.headerExists(SUSPEND_PROCESSING_HEADER))
                {                   
                    suspend();
                    responseMessage = null; // Don't hang on to this response.
                    return;
                }
            }
            catch (MessageException e)
            {
                context.setStatus(MessageIOConstants.STATUS_ERR);
               
                responseMessage = e.createErrorMessage();
                ((ErrorMessage)responseMessage).setCorrelationId(inMessage.getMessageId());
                ((ErrorMessage)responseMessage).setDestination(inMessage.getDestination());
                ((ErrorMessage)responseMessage).setClientId(inMessage.getClientId());
   
                e.logAtHingePoint(inMessage, (ErrorMessage)responseMessage, null /* Use default message intros */);   
            }
            catch (Throwable t)
            {
                // Handle any uncaught failures. The normal exception path on the server
                // is to throw MessageExceptions which are handled in the catch block above,
                // so if that was skipped we have an overlooked or serious problem.
                context.setStatus(MessageIOConstants.STATUS_ERR);
               
                MessageException lme = new MessageException();
                lme.setMessage(UNHANDLED_ERROR, new Object[] {t.getMessage()});
               
                responseMessage = lme.createErrorMessage();
                ((ErrorMessage)responseMessage).setCorrelationId(inMessage.getMessageId());
                ((ErrorMessage)responseMessage).setDestination(inMessage.getDestination());
                ((ErrorMessage)responseMessage).setClientId(inMessage.getClientId());
               
                if (Log.isError())
View Full Code Here

                    map = subscribersPerSubtopic;

                topicSub = (TopicSubscription) map.get(subtopic);

                if (topicSub == null)
                    throw new MessageException("Client: " + clientId + " not subscribed to subtopic: " + subtopic);
            }

            if (selector == null)
                subs = topicSub.defaultSubscriptions;
            else
                subs = (Map) topicSub.selectorSubscriptions.get(selector);

            if (subs == null || subs.get(clientId) == null)
                throw new MessageException("Client: " + clientId + " not subscribed to destination with selector: " + selector);

            synchronized (this)
            {
                subs.remove(clientId);
                if (subs.isEmpty() &&
View Full Code Here

        MessageBody responseBody = new MessageBody();
        responseBody.setTargetURI(context.getRequestMessageBody().getResponseURI());

        context.getResponseMessage().addBody(responseBody);

        MessageException methodResult;

        if (t instanceof MessageException)
        {
            methodResult = (MessageException)t;
        }
        else
        {
            // An unhandled error occurred while processing client request(s).
            methodResult = new SerializationException();
            methodResult.setMessage(UNHANDLED_SERIALIZATION_ERROR);
            methodResult.setRootCause(t);
        }

        responseBody.setReplyMethod(MessageIOConstants.STATUS_METHOD);
        responseBody.setData(methodResult);       
View Full Code Here

        {
            inMessage = (Message)data;
        }
        else
        {
            throw new MessageException("Request was not of type flex.messaging.messages.Message");
        }

        Object outMessage = null;

        String replyMethodName = MessageIOConstants.STATUS_METHOD;

        try
        {
            // Lookup or create the correct FlexClient.
            endpoint.setupFlexClient(inMessage);

            // Assign a clientId if necessary.
            // We don't need to assign clientIds to general poll requests.
            if (inMessage.getClientId() == null &&
                (!(inMessage instanceof CommandMessage) || ((CommandMessage)inMessage).getOperation() != CommandMessage.POLL_OPERATION))
            {
                Object clientId = UUIDUtils.createUUID();
                inMessage.setClientId(clientId);
            }

            // Messages received via the AMF channel can be batched (by NetConnection on the client) and
            // we must not put the handler thread into a poll-wait state if a poll command message is followed by
            // 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())
                MessagePerformanceUtils.setupMPII(context, inMessage);

            // Service the message.
            outMessage = endpoint.serviceMessage(inMessage);

            // if processing of the message resulted in an error, set up context and reply method accordingly
            if (outMessage instanceof ErrorMessage)
            {
                context.setStatus(MessageIOConstants.STATUS_ERR);
                replyMethodName = MessageIOConstants.STATUS_METHOD;
            }
            else
            {
                replyMethodName = MessageIOConstants.RESULT_METHOD;
            }
        }
        catch (MessageException e)
        {
            context.setStatus(MessageIOConstants.STATUS_ERR);
            replyMethodName = MessageIOConstants.STATUS_METHOD;

            outMessage = e.createErrorMessage();
            ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
            ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
            ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());

            e.logAtHingePoint(inMessage, (ErrorMessage)outMessage, null /* Use default message intros */);
        }
        catch (Throwable t)
        {
            // Handle any uncaught failures. The normal exception path on the server
            // is to throw MessageExceptions which are handled in the catch block above,
            // so if that was skipped we have an overlooked or serious problem.
            context.setStatus(MessageIOConstants.STATUS_ERR);
            replyMethodName = MessageIOConstants.STATUS_METHOD;

            String lmeMessage = t.getMessage();
            if (lmeMessage == null)
                lmeMessage = t.getClass().getName();

            MessageException lme = new MessageException();
            lme.setMessage(UNHANDLED_ERROR, new Object[] {lmeMessage});

            outMessage = lme.createErrorMessage();
            ((ErrorMessage)outMessage).setCorrelationId(inMessage.getMessageId());
            ((ErrorMessage)outMessage).setDestination(inMessage.getDestination());
            ((ErrorMessage)outMessage).setClientId(inMessage.getClientId());

            if (Log.isError())
View Full Code Here

            {
                version = Integer.parseInt(ver);
            }
            catch (NumberFormatException ex)
            {
                throw new MessageException("Unknown version: " + ver);
            }
        }

        if (isDebug)
            trace.version(version);
View Full Code Here

    }

    public void start_header(Attributes attributes)
    {
        if (currentHeader != null || currentBody != null)
            throw new MessageException("Unexpected header tag.");

        currentHeader = new MessageHeader();

        String name = attributes.getValue("name");
        currentHeader.setName(name);
View Full Code Here

    }

    public void start_body(Attributes attributes)
    {
        if (currentBody != null || currentHeader != null)
            throw new MessageException("Unexpected body tag.");

        currentBody = new MessageBody();

        String targetURI = attributes.getValue("targetURI");
        currentBody.setTargetURI(targetURI);
View Full Code Here

                if (length < 0)
                    throw new NumberFormatException();
            }
            catch (NumberFormatException ex)
            {
                throw new MessageException("Invalid array length: " + len);
            }
        }


        String ecma = attributes.getValue("ecma");
View Full Code Here

            ecmaArrayIndexStack.pop();
            strictArrayIndexStack.pop();
        }
        catch (EmptyStackException ex)
        {
            throw new MessageException("Unexpected end of array");
        }

        if (isDebug)
            trace.endAMFArray();
    }
View Full Code Here

TOP

Related Classes of flex.messaging.MessageException

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.