Re: Message queues
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Fri, 29 Feb 2008 10:23:54 -0700
Can't help you with Vista.
There's little sample code for Windows CE and 97% of the problems I've had
have been configuration problems or just the service not running.
Paul T.
"David" <david@xxxxxxxxxxx> wrote in message
news:652CA04B-82DF-4FA1-8C94-6D2192ECA40B@xxxxxxxxxxxxxxxx
A slightly different issue. This is all on the Vista machine, not the iPAQ
now. Here is some code. The m_queue.BeginReceive method gets called, but
after a few seconds it throws an exception which is caught, but the ex
variable is null. My MessageArrived method is never called either even
though I have added it to the ReceiveCompleted event. Now I dont know what
to do. This is pretty darn simple code. I can see two messages in the queue
on david-1. I can run the server app on david-1 at the same time as the
remote side is running. The server app creates new entries but still the
MessageArrived handler is not called and a bogus exception is thrown.
Ideas?
public partial class Form1 : Form
{
private MessageQueue m_queue;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
string deviceIP = String.Empty;
IPAddress[] addresses =
Dns.GetHostEntry("david-1").AddressList;
for (int i = 0; i < addresses.Length; ++i)
{
IPAddress addr = addresses[i];
if (addr.AddressFamily == AddressFamily.InterNetwork)
{
deviceIP = addr.ToString();
break;
}
}
if (deviceIP == String.Empty)
{
MessageBox.Show("Unable to retrieve Device IP");
Close();
return;
}
String strPath =
String.Format(@"FormatName:DIRECT=TCP:{0}\PRIVATE$\CallerID", deviceIP);
m_queue = new MessageQueue(strPath);
if (m_queue != null)
{
System.Type[] types = new Type[1];
types[0] = typeof(CallerIDClient.CallerID);
m_queue.Formatter = new XmlMessageFormatter(types);
try
{
m_queue.ReceiveCompleted += new
ReceiveCompletedEventHandler(MessageArrived);
}
catch (MessageQueueException ex)
{
MessageBox.Show(ex.Message);
Close();
}
Thread t1 = new Thread(PeekMessages);
t1.IsBackground = true;
t1.Start();
}
else
{
MessageBox.Show("Queue not created");
Close();
}
}
catch (MessageQueueException ex)
{
MessageBox.Show(ex.Message);
return;
}
}
private void PeekMessages()
{
while (true)
{
try
{
m_queue.BeginReceive();
}
catch (MessageQueueException ex)
{
MessageBox.Show(ex.Message);
return;
}
}
}
public void MessageArrived(Object source, ReceiveCompletedEventArgs
args)
{
MessageQueue queue = source as MessageQueue;
Message message = queue.EndReceive(args.AsyncResult);
CallerIDClient.CallerID callerid = message.Body as
CallerIDClient.CallerID;
if (callerid != null)
{
ListViewItem lvi = new ListViewItem(callerid.Name);
lvi.SubItems.Add(callerid.Number);
listView1.Items.Add(lvi);
}
}
private void AddItem(String strID)
{
Message message = m_queue.PeekById(strID);
CallerIDClient.CallerID callerid = message.Body as
CallerIDClient.CallerID;
if (callerid != null)
{
ListViewItem lvi = new ListViewItem(callerid.Name);
lvi.SubItems.Add(callerid.Number);
listView1.Items.Add(lvi);
}
}
}
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%23NHqHKveIHA.5164@xxxxxxxxxxxxxxxxxxxxxxx
Hmmm. Well, that suggests that you don't have network continuity between
where you are and where the queue is or that you don't have message queue
running on the device or, maybe, on the PC. Doesn't the MSMQ for your
device come with some sort of administrative tool for checking the
status, etc.? Can you ping or otherwise verify network connectivity
between the two ends of your communication path?
Paul T.
"David" <david@xxxxxxxxxxx> wrote in message
news:F742D99F-CFC2-4F61-B4C7-86E5684A93D0@xxxxxxxxxxxxxxxx
I have tried this on both the iPAQ and the Vista-32 machine:
if
(!MessageQueue.Exists(@"FormatName:DIRECT=TCP:10.0.0.20\private$\callerid"))
I get this error:
Cannot determine whether a queue with the specified format name exists
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
news:%23lrJHAveIHA.5788@xxxxxxxxxxxxxxxxxxxxxxx
I think that you've left out the type of the path. Have you tried
DIRECT=OS:, etc.? It may simply be that the desktop framework is
constructing that for you by default and the CF is not or something.
Paul T.
"David" <david@xxxxxxxxxxx> wrote in message
news:032CACCF-46C0-44BA-B0EC-568FD335A770@xxxxxxxxxxxxxxxx
I have replaced the david-1 with the ip address of david-1, 10.0.0.20,
with the same results.
I now have a simple client on another Vista-32 machine. All I do is
call:
MessageQueue.Exists(@"david-1\private$\callerid")
I get an error stating that I have an invalid queue path name. What is
wrong with my path?
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
news:OJpW%23iueIHA.5400@xxxxxxxxxxxxxxxxxxxxxxx
I don't use MSMQ on a daily basis, but I've used this sort of string
DIRECT=OS:farside\\private$\\lp45incoming
before, where farside was the NetBIOS name of the system hosting the
queue. I'm not sure that DNS can be used to resolve the name, but the
name you're using is not being resolved with DNS, I'd bet.
Paul T.
"David" <david@xxxxxxxxxxx> wrote in message
news:F0908FCC-F9AB-41EA-A52C-F654773E82D0@xxxxxxxxxxxxxxxx
This is all .NET 3.5 with Visual Studio 2008
I have a simple app on Windows Vista-64 that creates a messaging
queue. FormatName:DIRECT=OS:david-1\private$\callerid.
The app then writes a couple of entries. I have verified that the
entries have been correctly created with the Computer Management
tool.
I now have a simple app written for the compact framework on an HP
iPAQ HP 2790. MSMQ has been installed on it. When I call
MessageQueue.Exists(@"david-1\private$\callerid"), it returns false.
I can call this code:
IPAddress[] addresses =
Dns.GetHostEntry("david-1").AddressList;
and the correct address comes back so I know networking and dns are
working properly.
Is there something special that I have to do on the Vista-64 machine
or on the iPAQ to make this work?
.
- References:
- Message queues
- From: David
- Re: Message queues
- From: Paul G. Tobey [eMVP]
- Re: Message queues
- From: David
- Re: Message queues
- From: Paul G. Tobey [eMVP]
- Re: Message queues
- From: David
- Re: Message queues
- From: Paul G. Tobey [eMVP]
- Re: Message queues
- From: David
- Message queues
- Prev by Date: Re: Message queues
- Next by Date: Re: Functionality of the compact framework
- Previous by thread: Re: Message queues
- Next by thread: Re: Message queues
- Index(es):
Relevant Pages
|