Package flex.messaging

Examples of flex.messaging.MessageException


            {
                removeConsumer(consumer, true, true, messageEx.createErrorMessage());
            }
            catch (Exception ex)
            {
                removeConsumer(consumer, true, true, new MessageException(ex).createErrorMessage());
            }
        }
    }
View Full Code Here


     * @param clientId The identifier for the consumer to remove.
     */
    public void removeConsumer(String clientId)
    {
        // Client is unsubscribed because its corresponding JMS consumer has been removed from the JMS adapter.
        MessageException messageEx = new MessageException();
        messageEx.setMessage(JMSConfigConstants.CLIENT_UNSUBSCRIBE_DUE_TO_CONSUMER_REMOVAL);
        removeConsumer(clientId, true, true, messageEx.createErrorMessage());
    }
View Full Code Here

                            String name = pair.getProperty(NAME);
                            String value = pair.getProperty(VALUE);
                            if (name == null || value == null)
                            {
                                // A <property> element for the <initial-context-environment> settings for the ''{0}'' destination does not specify both <name> and <value> subelements.
                                MessageException messageEx = new MessageException();
                                messageEx.setMessage(MISSING_NAME_OR_VALUE, new Object[] {getDestination().getId()});
                                throw messageEx;
                            }
                            // If the name is a Context field, use the
                            // constant value rather than this literal name.
                            if (name.startsWith("Context."))
                            {
                                String fieldName = name.substring(name.indexOf(".") + 1);
                                java.lang.reflect.Field field = null;
                                try
                                {
                                    field = contextClass.getDeclaredField(fieldName);
                                }
                                catch (NoSuchFieldException nsfe)
                                {
                                    // A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an invalid javax.naming.Context field for its <name>: {1}
                                    MessageException messageEx = new MessageException();
                                    messageEx.setMessage(INVALID_CONTEXT_NAME, new Object[] {getDestination().getId(), fieldName});
                                    throw messageEx;
                                }
                                String fieldValue = null;
                                try
                                {
                                    fieldValue = (String)field.get(null);
                                }
                                catch (IllegalAccessException iae)
                                {
                                    // A <property> element for the <initial-context-environment> settings for the ''{0}'' destination specifies an inaccessible javax.naming.Context field for its <name>: {1}
                                    MessageException messageEx = new MessageException();
                                    messageEx.setMessage(INACCESIBLE_CONTEXT_NAME, new Object[] {getDestination().getId(), fieldName});
                                    throw messageEx;
                                }
                                envProps.put(fieldValue, value);
                            }
                            else
                            {
                                envProps.put(name, value);
                            }
                        }
                        else
                        {
                            // A <property> element for the <initial-context-environment> settings for the ''{0}'' destination does not specify both <name> and <value> subelements.
                            MessageException messageEx = new MessageException();
                            messageEx.setMessage(MISSING_NAME_OR_VALUE, new Object[] {getDestination().getId()});
                            throw messageEx;
                        }
                    }
                    settings.setInitialContextEnvironment(envProps);
                }
                else
                {
                    // The <initial-context-environment> settings for the ''{0}'' destination does not include any <property> subelements.
                    MessageException messageEx = new MessageException();
                    messageEx.setMessage(MISSING_PROPERTY_SUBELEMENT, new Object[] {getDestination().getId()});
                    throw messageEx;
                }
            }
        }
    }
View Full Code Here

        Iterator<JMSConsumer> itr = consumers.iterator();
        while (itr.hasNext())
        {
            JMSConsumer consumer = itr.next();
            // Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' has been stopped.
            MessageException me = new MessageException();
            me.setMessage(JMSConfigConstants.CLIENT_UNSUBSCRIBE_DUE_TO_CONSUMER_STOP, new Object[] {consumer.getDestinationJndiName()});
            consumer.stop(true);
            invalidateMessageClient(consumer, me.createErrorMessage());
        }
    }
View Full Code Here

                    setValue(s);
                }
            }
            catch (NumberFormatException ex)
            {
                throw new MessageException("Invalid string reference: " + id);
            }
            catch (IndexOutOfBoundsException ex)
            {
                throw new MessageException("Unknown string reference: " + id);
            }
        }
        else
        {
            text.delete(0, text.length());
View Full Code Here

                        traitsList.add(prop);
                    }
                }
                catch (NumberFormatException ex)
                {
                    throw new MessageException("Invalid traits reference: " + id);
                }
                catch (IndexOutOfBoundsException ex)
                {
                    throw new MessageException("Unknown traits reference: " + id);
                }
            }
            else
            {
                boolean externalizable = false;

                String ext = attributes.getValue("externalizable");
                if (ext != null)
                {
                    externalizable = "true".equals(ext.trim());
                }

                Object obj = objectStack.peek();
                if (externalizable && !(obj instanceof Externalizable))
                {
                    //Class '{className}' must implement java.io.Externalizable to receive client IExternalizable instances.
                    SerializationException ex = new SerializationException();
                    ex.setMessage(10305, new Object[] {obj.getClass().getName()});
                    throw ex;
                }

                traitsTable.add(traitsList);
            }

            isTraitProperty = true;
        }
        else
        {
            throw new MessageException("Unexpected traits");
        }
    }
View Full Code Here

                currentBody.setData(value);
            }

            else
            {
                throw new MessageException("Unexpected value: " + value);
            }

            return;
        }


        // ActionScript Data
        Object obj = objectStack.peek();

        // <object type="..."> <traits externalizable="true">
        if (obj instanceof Externalizable)
        {
            if (value != null && value.getClass().isArray() && Byte.TYPE.equals(value.getClass().getComponentType()))
            {
                Externalizable extern = (Externalizable)obj;
                Amf3Input objIn = new Amf3Input(context);
                byte[] ba = (byte[])value;
                ByteArrayInputStream baIn = new ByteArrayInputStream(ba);
                try
                {
                    //objIn.setDebugTrace(trace);
                    objIn.setInputStream(baIn);
                    extern.readExternal(objIn);
                }
                catch (ClassNotFoundException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                catch (IOException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                finally
                {
                    try
                    {
                        objIn.close();
                    }
                    catch (IOException ex)
                    {
                    }
                }
            }
            else
            {
                throw new MessageException("Error while reading Externalizable class. Value must be a byte array.");
            }
        }

        // <object>
        else if (obj instanceof ASObject)
        {
            String prop;

            TraitsContext traitsContext = (TraitsContext)traitsStack.peek();
            try
            {
                prop = traitsContext.next();
            }
            catch (IndexOutOfBoundsException ex)
            {
                throw new MessageException("Object has no trait info for value: " + value);
            }

            ASObject aso = (ASObject)obj;
            aso.put(prop, value);

            if (isDebug)
                trace.namedElement(prop);
        }

        // <array ecma="false"> in ArrayList form
        else if (obj instanceof ArrayList && !(obj instanceof ArrayCollection))
        {
            ArrayList list = (ArrayList)obj;
            list.add(value);

            if (isDebug)
                trace.arrayElement(list.size() - 1);

        }

        // <array ecma="false"> in Object[] form
        else if (obj.getClass().isArray())
        {
            if (!strictArrayIndexStack.empty())
            {
                int[] indexObj = (int[])strictArrayIndexStack.peek();
                int index = indexObj[0];

                if (Array.getLength(obj) > index)
                {
                    Array.set(obj, index, value);
                }
                else
                {
                    throw new MessageException("Index out of bounds at: " + index + " cannot set array value: " + value + "");
                }
                indexObj[0]++;
            }
        }

        // <array ecma="true">
        else if (obj instanceof Map)
        {
            Map map = (Map)obj;

            // <item name="prop">
            if (!arrayPropertyStack.empty())
            {
                String prop = (String)arrayPropertyStack.peek();
                map.put(prop, value);

                if (isDebug)
                    trace.namedElement(prop);

                return;
            }

            // Mixed content, auto-generate string for ECMA Array index
            if (!ecmaArrayIndexStack.empty())
            {
                int[] index = (int[])ecmaArrayIndexStack.peek();

                String prop = String.valueOf(index[0]);
                index[0]++;

                map.put(prop, value);

                if (isDebug)
                    trace.namedElement(prop);
            }
        }

        // <object type="...">
        else
        {
            String prop;

            TraitsContext traitsContext = (TraitsContext)traitsStack.peek();
            try
            {
                prop = traitsContext.next();
            }
            catch (IndexOutOfBoundsException ex)
            {
                throw new MessageException("Object has no trait info for value: " + value, ex);
            }

            try
            {
                // Then check if there's a more suitable proxy now that we have an instance
                PropertyProxy proxy = (PropertyProxy) proxyStack.peek();
                if (proxy == null)
                    proxy = beanproxy;
                proxy.setValue(obj, prop, value);
            }
            catch (Exception ex)
            {
                throw new MessageException("Failed to set property '" + prop + "' with value: " + value, ex);
            }


            if (isDebug)
                trace.namedElement(prop);
View Full Code Here

                    if (throttleResultCode != ThrottleResult.RESULT_OK && isManaged())
                        ((ThrottleManagerControl)getControl()).incrementDestinationIncomingMessageThrottleCount();

                    String s = "Message throttled: Too many messages sent to destination "
                        + inboundDestinationMark.id + " in too small of a time interval.  " + e.getMessage();
                    MessageException me = new MessageException(s);
                    result = new ThrottleResult(throttleResultCode, me);
                }
            }
            else
            {
                try
                {
                    outboundDestinationMark.assertValid(msg.getTimestamp(), settings.getOutgoingDestinationFrequency());
                }
                catch (RuntimeException e)
                {
                    int throttleResultCode = getResultCode(settings.getOutboundPolicy());

                    // Update the management metrics.
                    if (throttleResultCode != ThrottleResult.RESULT_OK && isManaged())
                        ((ThrottleManagerControl)getControl()).incrementDestinationOutgoingMessageThrottleCount();

                    String s = "Message throttled: Too many messages routed by destination "
                        + outboundDestinationMark.id + " in too small of a time interval";
                    MessageException me = new MessageException(s);
                    result = new ThrottleResult(throttleResultCode, me);
                }
            }
        }
        return result;
View Full Code Here

                    if ((throttleResultCode != ThrottleResult.RESULT_OK) && isManaged())
                        ((ThrottleManagerControl)getControl()).incrementClientIncomingMessageThrottleCount();

                    String s = "Message throttled: Too many messages sent by client "
                        + clientId + " in too small of a time interval";
                    MessageException me = new MessageException(s);
                    result = new ThrottleResult(throttleResultCode, me);
                }
                finally
                {
                    inboundClientMarks.put(clientId, clientLevelMark);
                }
            }
            else
            {
                clientLevelMark = outboundClientMarks.get(clientId);
                if (clientLevelMark == null)
                    clientLevelMark = new ThrottleMark(clientId);
                try
                {
                    clientLevelMark.assertValid(msg.getTimestamp(), settings.getOutgoingClientFrequency());
                }
                catch (RuntimeException e)
                {
                    int throttleResultCode = getResultCode(settings.getOutboundPolicy());

                    // Update the management metrics.
                    if ((throttleResultCode != ThrottleResult.RESULT_OK) && isManaged())
                        ((ThrottleManagerControl)getControl()).incrementClientOutgoingMessageThrottleCount();

                    String s = "Message throttled: Too many messages sent to client "
                        + clientId + " in too small of a time interval";
                    MessageException me = new MessageException(s);
                    result = new ThrottleResult(throttleResultCode, me);
                }
                finally
                {
                    outboundClientMarks.put(clientId, clientLevelMark);
View Full Code Here

        private void add(String trait)
        {
            trait = trait.trim();

            if (trait.length() <= 0)
                throw new MessageException("Traits cannot be the empty string.");

            char c = trait.charAt(0);
            if (!(Character.isLetterOrDigit(c) || c == '_'))
                throw new MessageException("Invalid trait name: " + trait +
                        ". Object property names must start with a letter, a digit or the underscore '_' character.");


            traits.add(trait);
        }
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.