activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Gomes (JIRA)" <jira+amq...@apache.org>
Subject [jira] Commented: (AMQNET-101) Support System.Messaging.MessagePriority
Date Thu, 14 Aug 2008 01:07:52 GMT

    [ https://issues.apache.org/activemq/browse/AMQNET-101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44952#action_44952
] 

Jim Gomes commented on AMQNET-101:
----------------------------------

Here is a sample piece of code of what could be implemented to simulate the MessagePriority
enum and improve code readability.  This would have no impact on current code.  To address
the concerns that Mark pointed out, it would create no new dependencies on {{System.Messaging}},
and would support all 10 values of delivery priorites.

{code:title=Enum-like behavior example|borderStyle=solid}
using System;

public class MessagePriorityTest
{
    public struct MsgPriority
    {
        private byte priority;

        public const byte Lowest         = 0;
        public const byte VeryLow        = 1;
        public const byte Low            = 2;
        public const byte AboveLow       = 3;
        public const byte BelowNormal    = 4;
        public const byte Normal         = 5;
        public const byte AboveNormal    = 6;
        public const byte High           = 7;
        public const byte VeryHigh       = 8;
        public const byte Highest        = 9;

        public MsgPriority(byte newpriority)
        {
            this.priority = newpriority;
        }

        public MsgPriority(int newpriority)
                : this((byte) newpriority)
        {
        }

        public MsgPriority(MsgPriority msgpriority)
                : this(msgpriority.priority)
        {
        }

        public static implicit operator byte(MsgPriority rhs)
        {
            return rhs.priority;
        }

        public static implicit operator MsgPriority(byte rhs)
        {
            return new MsgPriority(rhs);
        }

        public static implicit operator MsgPriority(int rhs)
        {
            return new MsgPriority(rhs);
        }
    }

    protected static void PrintMsgPriority(MsgPriority mp)
    {
        Console.WriteLine("{0} = {1}", mp, (byte) mp);
    }

    public static void Main()
    {
        byte lowest = MsgPriority.Lowest;
        MsgPriority mp = 7;

        PrintMsgPriority(lowest);
        PrintMsgPriority(MsgPriority.Highest);
        PrintMsgPriority(mp);
        PrintMsgPriority(4);
        PrintMsgPriority(22);
    }
}
{code}


> Support System.Messaging.MessagePriority
> ----------------------------------------
>
>                 Key: AMQNET-101
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-101
>             Project: ActiveMQ .Net
>          Issue Type: Improvement
>          Components: ActiveMQ Client, EMS, MSMQ, Stomp
>    Affects Versions: 1.1
>            Reporter: Jim Gomes
>            Assignee: Jim Gomes
>             Fix For: 1.1
>
>   Original Estimate: 1 day
>  Remaining Estimate: 1 day
>
> The Priority field on IMessageProducer, and IMessage is currently an untyped byte.  It
would be better to integrate with .NET System.Messaging.MessagePriority enumeration to make
the code more readable and have a more .NET behavior.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message