public void TestConvertProperties() { ActiveMQMessage msg = new ActiveMQMessage(); msg.Properties["stringProperty"] = "string"; msg.Properties["byteProperty"] = (Byte)1; msg.Properties["shortProperty"] = (Int16)1; msg.Properties["intProperty"] = (Int32)1; msg.Properties["longProperty"] = (Int64)1; msg.Properties["floatProperty"] = (Single)1.1f; msg.Properties["doubleProperty"] = (Double)1.1; msg.Properties["booleanProperty"] = (Boolean)true; msg.Properties["nullProperty"] = null; msg.BeforeMarshall(new OpenWireFormat()); IPrimitiveMap properties = msg.Properties; Assert.AreEqual(properties["stringProperty"], "string"); Assert.AreEqual((byte)properties["byteProperty"], (byte)1); Assert.AreEqual((short)properties["shortProperty"], (short)1); Assert.AreEqual((int)properties["intProperty"], (int)1); Assert.AreEqual((long)properties["longProperty"], (long)1); Assert.AreEqual((float)properties["floatProperty"], 1.1f, 0); Assert.AreEqual((double)properties["doubleProperty"], 1.1, 0); Assert.AreEqual((bool)properties["booleanProperty"], true); Assert.IsNull(properties["nullProperty"]); }
protected virtual void WriteMessage(ActiveMQMessage command, StompFrameStream ss) { ss.WriteCommand(command, "SEND"); ss.WriteHeader("destination", StompHelper.ToStomp(command.Destination)); if (command.ReplyTo != null) { ss.WriteHeader("reply-to", StompHelper.ToStomp(command.ReplyTo)); } if (command.CorrelationId != null) { ss.WriteHeader("correlation-id", command.CorrelationId); } if (command.Expiration != 0) { ss.WriteHeader("expires", command.Expiration); } if (command.Priority != 4) { ss.WriteHeader("priority", command.Priority); } if (command.Type != null) { ss.WriteHeader("type", command.Type); } if (command.TransactionId != null) { ss.WriteHeader("transaction", StompHelper.ToStomp(command.TransactionId)); } ss.WriteHeader("persistent", command.Persistent); // lets force the content to be marshalled command.BeforeMarshall(null); if (command is ActiveMQTextMessage) { ActiveMQTextMessage textMessage = command as ActiveMQTextMessage; ss.Content = encoding.GetBytes(textMessage.Text); } else { ss.Content = command.Content; if (null != command.Content) { ss.ContentLength = command.Content.Length; } else { ss.ContentLength = 0; } } IPrimitiveMap map = command.Properties; foreach (string key in map.Keys) { ss.WriteHeader(key, map[key]); } ss.Flush(); }
// // Write the booleans that this object uses to a BooleanStream // public override int TightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) { ActiveMQMessage info = (ActiveMQMessage)o; info.BeforeMarshall(wireFormat); int rc = base.TightMarshal1(wireFormat, o, bs); return(rc + 0); }
// // Write a object instance to data output stream // public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) { ActiveMQMessage info = (ActiveMQMessage)o; info.BeforeMarshall(wireFormat); base.LooseMarshal(wireFormat, o, dataOut); info.AfterMarshall(wireFormat); }