public void TestMethod_InterfaceSendReceive() { string testName = "InterfaceSendReceive"; const int nMsgs = 200; IConnection connection = new Connection(testTarget.Address); ISession session = connection.CreateSession(); ISenderLink sender = session.CreateSender("sender-" + testName, testTarget.Path); for (int i = 0; i < nMsgs; ++i) { Message message = new Message("msg" + i); message.Properties = new Properties() { GroupId = "abcdefg" }; message.ApplicationProperties = new ApplicationProperties(); message.ApplicationProperties["sn"] = i; sender.Send(message, null, null); } IReceiverLink receiver = session.CreateReceiver("receiver-" + testName, testTarget.Path); for (int i = 0; i < nMsgs; ++i) { Message message = receiver.Receive(); Trace.WriteLine(TraceLevel.Verbose, "receive: {0}", message.ApplicationProperties["sn"]); receiver.Accept(message); } connection.Close(); }
private void Send_Click(object sender, EventArgs e) { if (senderLink == null) { AddSender(); if (senderLink == null) { return; } } Data data = new Data(); data.Binary = input.SelectedBinaryValue; Amqp.Message message = new Amqp.Message(); message.BodySection = data; message.Header = new Header() { }; message.Properties = new Amqp.Framing.Properties(); if (!string.IsNullOrWhiteSpace(subject.Text)) { message.Properties.Subject = subject.Text; } try { senderLink.Send(message, (s, m, outcome, state) => { }, null); } catch (AmqpException ex) { MessageBox.Show(this, ex.Message); return; } }
public void TestMethod_InterfaceSendReceiveOnAttach() { string testName = "InterfaceSendReceiveOnAttach"; const int nMsgs = 200; int nAttaches = 0; OnAttached onAttached = (link, attach) => { nAttaches++; }; IConnection connection = new Connection(testTarget.Address); ISession session = connection.CreateSession(); ISenderLink sender = session.CreateSender("sender-" + testName, new Target() { Address = testTarget.Path }, onAttached); for (int i = 0; i < nMsgs; ++i) { Message message = new Message("msg" + i); message.Properties = new Properties() { GroupId = "abcdefg" }; message.ApplicationProperties = new ApplicationProperties(); message.ApplicationProperties["sn"] = i; sender.Send(message, null, null); } IReceiverLink receiver = session.CreateReceiver("receiver-" + testName, new Source() { Address = testTarget.Path }, onAttached); for (int i = 0; i < nMsgs; ++i) { Message message = receiver.Receive(); Trace.WriteLine(TraceLevel.Verbose, "receive: {0}", message.ApplicationProperties["sn"]); receiver.Accept(message); } Assert.AreEqual(2, nAttaches); connection.Close(); }