protected virtual void WriteMessage(Message command, BinaryWriter dataOut) { var frame = new StompFrame("SEND", _encodeHeaders); if (command.ResponseRequired) { frame.SetProperty("receipt", command.CommandId); } frame.SetProperty("destination", Destination.ConvertToStompString(command.Destination)); if (command.ReplyTo != null) { frame.SetProperty("reply-to", Destination.ConvertToStompString(command.ReplyTo)); } if (command.CorrelationId != null) { frame.SetProperty("correlation-id", command.CorrelationId); } if (command.Expiration != 0) { frame.SetProperty("expires", command.Expiration); } if (command.Timestamp != 0) { frame.SetProperty("timestamp", command.Timestamp); } if (command.Priority != 4) { frame.SetProperty("priority", command.Priority); } if (command.Type != null) { frame.SetProperty("type", command.Type); } if (command.TransactionId != null) { frame.SetProperty("transaction", command.TransactionId.ToString()); } frame.SetProperty("persistent", command.Persistent.ToString() .ToLower()); frame.SetProperty("NMSXDeliveryMode", command.Persistent.ToString() .ToLower()); if (command.StompGroupId != null) { frame.SetProperty("JMSXGroupID", command.StompGroupId); frame.SetProperty("NMSXGroupID", command.StompGroupId); frame.SetProperty("JMSXGroupSeq", command.StompGroupSeq); frame.SetProperty("NMSXGroupSeq", command.StompGroupSeq); } // Perform any Content Marshaling. command.BeforeMarshall(this); // Store the Marshaled Content. frame.Content = command.Content; if (command is BytesMessage) { if (command.Content != null && command.Content.Length > 0) { frame.SetProperty("content-length", command.Content.Length); } frame.SetProperty("transformation", "jms-byte"); } // Marshal all properties to the Frame. var map = command.Headers; foreach (var key in map.Keys) { frame.SetProperty(key, map[key]); } frame.ToStream(dataOut); }
protected virtual void WriteConsumerInfo(ConsumerInfo command, BinaryWriter dataOut) { StompFrame frame = new StompFrame("SUBSCRIBE"); if (command.ResponseRequired) { frame.SetProperty("receipt", command.CommandId); } frame.SetProperty("destination", Destination.ConvertToStompString(command.Destination)); frame.SetProperty("id", command.ConsumerId.ToString()); frame.SetProperty("durable-subscriber-name", command.SubscriptionName); frame.SetProperty("selector", command.Selector); frame.SetProperty("ack", StompHelper.ToStomp(command.AckMode)); if (command.NoLocal) { frame.SetProperty("no-local", command.NoLocal.ToString()); } // ActiveMQ extensions to STOMP if (command.Transformation != null) { frame.SetProperty("transformation", command.Transformation); } else { frame.SetProperty("transformation", "jms-xml"); } frame.SetProperty("activemq.dispatchAsync", command.DispatchAsync); if (command.Exclusive) { frame.SetProperty("activemq.exclusive", command.Exclusive); } if (command.SubscriptionName != null) { frame.SetProperty("activemq.subscriptionName", command.SubscriptionName); // For an older 4.0 broker we need to set this header so they get the // subscription as well.. frame.SetProperty("activemq.subcriptionName", command.SubscriptionName); } frame.SetProperty("activemq.maximumPendingMessageLimit", command.MaximumPendingMessageLimit); frame.SetProperty("activemq.prefetchSize", command.PrefetchSize); frame.SetProperty("activemq.priority", command.Priority); if (command.Retroactive) { frame.SetProperty("activemq.retroactive", command.Retroactive); } if (Tracer.IsDebugEnabled) { Tracer.Debug("StompWireFormat - Writing " + frame.ToString()); } frame.ToStream(dataOut); }