Использование MSMQ через HTTP. Как обратиться к очереди?C#

Место общения программистов C#
Ответить
Anonymous
 Использование MSMQ через HTTP. Как обратиться к очереди?

Сообщение Anonymous »

Я в настоящее время пытаюсь использовать MSMQ с C# и .NET для достижения IPC.
Я пытаюсь понять, как он работает, и я весьма смущен различиями между именем пути и именем формата при доступе к очереди MSMQ.
Я нашел некоторые подобные проблемы в следующих постах: < /p>










Как настроить сервер MSMQ, чтобы к нему можно было получить доступ через Интернет < /li>
Как использовать MSMQ через HTTP через соответствующее связывание WCF? />
Чего я хочу достичь, - это следующее: < /p>

client: < /strong> отправляет данные в очередь через http < /strong>. < /p>

server: < /strong> получает данные от Queueue < /plorn>. /> Я хочу, чтобы я хочу, чтобы на сервере , клиент и очередь < /em> были размещены в потенциально разных компьютерах. (На данный момент я тестирую все в той же машине). < /P>

Здесь у меня есть следующий код, который демонстрирует, что я имею в виду: < /p>

Сначала я создаю очередь: < /p>

Код: Выделить всё

if(!System.Messaging.MessageQueue.Exists(@".\Private$\SimplestExamplePrivateQueue");
System.Messaging.MessageQueue.Create(@".\Private$\SimplestExamplePrivateQueue");
< /code>

 Client Code: < /strong> < /p>

Затем, на стороне клиента, у меня есть функция обратного вызова, которая вызывается, когда пользователь нажимает кнопку, чтобы отправить сообщение. < /p>

private void button1_Click(object sender, System.EventArgs e)
{
try
{
// Create a connection to the queue
System.Messaging.MessageQueue mq = new System.Messaging.MessageQueue(@"FormatName:Direct=http://localhost/msmq/Private$/SimplestExamplePrivateQueue");

// Create a point object to send
Point myPoint = new Point (Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text)) ;

// Send object
mq.Send (myPoint) ;
}

// Catch the exception that signals all types of error
// from the message queueing subsystem. Report error
// to the user.
catch (System.Messaging.MessageQueueException mqx)
{
MessageBox.Show (mqx.Message) ;
}
Everything until here works fine.

Server code:[/b]

Then, I have a button which invokes a callback function to synchronously read one message from the queue at the server side:

private void button1_Click(object sender, EventArgs e)
{
try
{
// Create a connection to the queue
var mq = new MessageQueue(@"Direct=http://localhost/msmq/Private$/Simplest ... ivateQueue");

// Set the queue's formatter to decode Point objects
mq.Formatter = new XmlMessageFormatter(new[] {typeof (Point)});

// Receive message synchronously
Message msg = mq.Receive();

// Convert received message to object that we think was sent
var pt = (Point) msg.Body;

// Display it to the user
MessageBox.Show(pt.ToString(), "Received Point");
}

// Report any exceptions to the user. A timeout would cause such
// an exception
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
< /code>

В моем (ограниченном) понимании MSMQ это должно работать. Однако, когда я вызываю сообщение msg = mq.receive (); < /code> я получаю следующее исключение: < /p>

The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted.
< /code>

и трассировка стека: < /p>

at System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle()
at System.Messaging.MessageQueue.StaleSafeReceiveMessage(UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction)
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive()
at InternetQueueingRecipient.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\felipedalcin\Documents\MSMQ\MSMQandNET\InternetQueuing\InternetQueueingRecipient\Form1.cs:line 85
< /code>

У кого -нибудь есть представление о том, как я мог бы отладить это или даже если то, что я хочу сделать, достижимо этими средствами? < /p>

Подробнее здесь: https://stackoverflow.com/questions/194 ... -the-queue
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»