activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tamilmaran (JIRA)" <jira+amq...@apache.org>
Subject [jira] [Updated] (AMQNET-440) IObjectMessage.ToObject<T> is not working
Date Mon, 05 Aug 2013 13:33:48 GMT

     [ https://issues.apache.org/jira/browse/AMQNET-440?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tamilmaran updated AMQNET-440:
------------------------------

    Description: 

Hi

I am working on NMS API 1.6.0. i am not able to deserizile using the following object deserilization
mechanism

objMessage.ToObject<T> or

objMessage.ToObject() as T 

Please help us to overcome the issue.

Please find our codes below.

The code sample:

{code} 
           _consumer.Listener += new MessageListener(OnMessage);           
            Employee emp = new Employee();
            emp.FirstName = "raj";
            emp.LastName = "esh";
  
           IObjectMessage objectMessage = producer.CreateObjectMessage(emp);
           objectMessage.NMSType = emp.GetType().ToString();
           producer.Send(objectMessage);
{code}
{code}
protected static void OnMessage(IMessage receivedMsg)
{
    IObjectMessage objMessage = receivedMsg as IObjectMessage;

    //Following code is not working
    IEmployee emp = objMessage.ToObject<IEmployee>();

    //Following code is not working
    IEmployee emp1 = objMessage.ToObject() as IEmployee;

    //Following code is working
    IEmployee iEmp = objMessage.Body as IEmployee;//This code only is working
}

{code}

{code}
public interface IEmployee
    {
        string FirstName { get; set; }
        string LastName { get; set; }
    }
{code}

{code}
[Serializable]
    public class Employee : IEmployee
    {
        #region IEmployee Members
        private string _firstName;
        private string _lastName;

        public string FirstName
        {
            get
            {
                return this._firstName;
            }
            set
            {
                this._firstName = value;
            }
        }

        public string LastName
        {
            get
            {
                return this._lastName;
            }
            set
            {
                this._lastName = value;
            }
        }

        #endregion
    }
{code}


  was:
IObjectMessage.ToObject<T> is not working to achieve deserialization.
The code sample:

{code}
protected static void OnMessage(IMessage receivedMsg)
{
    objMessage = receivedMsg as IObjectMessage;

    //Following code is not working
    IEmployee emp = objMessage.ToObject<IEmployee>();

    //Following code is not working
    IEmployee emp1 = objMessage.ToObject() as IEmployee;

    //Following code is working
    IEmployee iEmp = objMessage.Body as IEmployee;//This code only is working
}

{code}

    
> IObjectMessage.ToObject<T> is not working
> -----------------------------------------
>
>                 Key: AMQNET-440
>                 URL: https://issues.apache.org/jira/browse/AMQNET-440
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>         Environment: activeMQ 5.8.0, C# API NMS 1.6.0
>            Reporter: Tamilmaran
>
> Hi
> I am working on NMS API 1.6.0. i am not able to deserizile using the following object
deserilization mechanism
> objMessage.ToObject<T> or
> objMessage.ToObject() as T 
> Please help us to overcome the issue.
> Please find our codes below.
> The code sample:
> {code} 
>            _consumer.Listener += new MessageListener(OnMessage);           
>             Employee emp = new Employee();
>             emp.FirstName = "raj";
>             emp.LastName = "esh";
>   
>            IObjectMessage objectMessage = producer.CreateObjectMessage(emp);
>            objectMessage.NMSType = emp.GetType().ToString();
>            producer.Send(objectMessage);
> {code}
> {code}
> protected static void OnMessage(IMessage receivedMsg)
> {
>     IObjectMessage objMessage = receivedMsg as IObjectMessage;
>     //Following code is not working
>     IEmployee emp = objMessage.ToObject<IEmployee>();
>     //Following code is not working
>     IEmployee emp1 = objMessage.ToObject() as IEmployee;
>     //Following code is working
>     IEmployee iEmp = objMessage.Body as IEmployee;//This code only is working
> }
> {code}
> {code}
> public interface IEmployee
>     {
>         string FirstName { get; set; }
>         string LastName { get; set; }
>     }
> {code}
> {code}
> [Serializable]
>     public class Employee : IEmployee
>     {
>         #region IEmployee Members
>         private string _firstName;
>         private string _lastName;
>         public string FirstName
>         {
>             get
>             {
>                 return this._firstName;
>             }
>             set
>             {
>                 this._firstName = value;
>             }
>         }
>         public string LastName
>         {
>             get
>             {
>                 return this._lastName;
>             }
>             set
>             {
>                 this._lastName = value;
>             }
>         }
>         #endregion
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message