1
我從C#中的ActiveMQ開始。 我將我的對象序列化爲json並毫無問題地發送它。如何使用Apache.NMS.ActiveMQ(C#)將自定義屬性添加到消息中?
我會添加屬性到我的消息,但我沒有成功。我在幾個網站上看到了setIntProperty(String name,int value),但是我沒有在Apache.NMS.ActiveMQ(C#)上找到它。
這裏我的代碼:
ActiveMQ mom = new ActiveMQ();
ISession session = mom.Initialize();
IDestination dest = session.GetQueue(queueDestination);
using (IMessageProducer producer = session.CreateProducer(dest))
{
foreach (Store s in stores)
{
List<string> matchKeyProductList = db.GetProductsKeyList(websiteNumberID);
ArrayList arCodesProdToUpdate = db.GetProductsToUpdate(websiteNumberID);
JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
serializer.MaxJsonLength = Int32.MaxValue; //Augmentation de la propriété MaxJsonLenth
MessageObject message = new MessageObject(matchKeyProductList, arCodesProdToUpdate);
string jsonMessage = serializer.Serialize(message);
ITextMessage textMessage = producer.CreateTextMessage(jsonMessage);
producer.Send(textMessage);
}
}
mom.Cleanup();
誰能幫我用一個例子嗎?
非常感謝!我沒有看到有屬性下面的方法... – Seb 2014-11-25 13:37:16