我正在使用STOMP協議讀/寫消息到/從Rabbit MQ(3.6.5)隊列。 我使用Apache NMS Stomp(1.5.4)作爲客戶端庫。使用Apache NMS與RabbitMQ相合STOMP
使用NMS發送消息時,出現下列異常:
輸入字符串格式不正確。
的原因是,NMS預計日提交郵件ID含有在特定位置的數字。
這是從NMS庫中的代碼:
public void SetValue(String messageKey)
{
key = messageKey;
// Parse off the sequenceId
var p = messageKey.LastIndexOf(":");
if (p >= 0)
{
ProducerSequenceId = Int64.Parse(messageKey.Substring(p + 1));
messageKey = messageKey.Substring(0, p);
}
ProducerId = new ProducerId(messageKey);
}
由兔MQ代理具有以下值發送的消息ID字段: 「T_ID:無花果52033-636066062974737556-1:0:1 :1 @@ session-10nNy1WnMfOTxEEVQmLHgg @@ 1「
NMS嘗試將」1 @@ session-Bo6HXXTZFSh51Qy7X4wx9A @@ 1「轉換爲Int64。
這是我的客戶端代碼:
var connecturi = new Uri("stomp:tcp://localhost:61613?transport.useInactivityMonitor=false&trace=true");
Console.WriteLine("About to connect to " + connecturi);
IConnectionFactory factory = new NMSConnectionFactory(connecturi);
using (var connection = factory.CreateConnection("XXXX", "XXXX"))
using (var session = connection.CreateSession())
{
connection.Start();
var destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
Console.WriteLine("Using destination: " + destination);
// Create a consumer and producer
using (var consumer = session.CreateConsumer(destination))
using (var producer = session.CreateProducer(destination))
{
// Start the connection so that messages will be processed.
producer.DeliveryMode = MsgDeliveryMode.Persistent;
// Send a message
var request = session.CreateTextMessage("Hello World! FROM NMS");
producer.Send(request);
// Consume a message
var message = consumer.Receive() as ITextMessage;
if (message == null)
{
Console.WriteLine("No message received!");
}
else
{
Console.WriteLine("Received message with ID: " + message.NMSMessageId);
Console.WriteLine("Received message with text: " + message.Text);
}
}
}
是否有一個解決這個問題?
- 一種配置NMS以不同方式處理id的方法?
- 一種告訴Rabbit MQ生成其他消息ID的方法嗎?