/// <summary> /// A Message receive callback delegate that prints the SDT content /// of received messages. /// </summary> /// <param name="source"></param> /// <param name="args"></param> public void PrintReceivedMessage(Object source, MessageEventArgs args) { IMessage message = args.Message; ISDTContainer container = SDTUtils.GetContainer(message); StringBuilder sb = new StringBuilder(); if (container is IMapContainer) { IMapContainer map = (IMapContainer)container; sb.Append("map={"); while (map.HasNext()) { KeyValuePair <string, ISDTField> entry = map.GetNext(); sb.Append(string.Format("\n\tkey={0} value={1}", entry.Key, entry.Value.Value.ToString())); } sb.Append("}\n"); } else if (container is IStreamContainer) { IStreamContainer stream = (IStreamContainer)container; sb.Append("stream={"); while (stream.HasNext()) { ISDTField entry = stream.GetNext(); sb.Append(string.Format("\n\tvalue={0}", entry.Value.ToString())); } sb.Append("}\n"); } SampleUtils.HandleMessageEvent(source, args); Console.WriteLine(sb.ToString()); }
private static void BuildHeaderMap(IMessage msg, IDictionary <string, object> outHeaders) { IMapContainer headers = msg.UserPropertyMap; if (headers == null) { return; } while (headers.HasNext()) { KeyValuePair <string, ISDTField> kv = headers.GetNext(); string key = kv.Key; outHeaders[key] = kv.Value.Value; } headers.Close(); }