MSMQ error, The stream has returned a read error

dr.burns
Member Posts: 6
Hello,
I have created a codeunit (code see below) and a form with a button. The OnPush trigger of the Button calls the function SendMSMQ() of the codeunit.
If I run the codeunit and I click the button in my form, an error message comes up:
The stream has returned a read error
I spent already one whole day to find out whats wrong, but I couldn't.
If I set the property WithEvents of CC2 to NO I can see the
message under Message queue tool of XP with the text Hello world in it. If I set it to yes again, the message seems to be collected from the event, because not visible anymore under the message queue manager of Windows XP.
I found out the error happens on execution of following line:
StreamIn.READTEXT(Text, MAXSTRLEN(Text));
Does anybody have an idea whats wrong?
Thanks a lot!
Here's the code of the codeunit:
Global vars:
MQBus:
Automation
'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter
CC2:
Automation
'Navision Communication Component version2'.CommunicationComponent
InMsg:
Automation
'Navision Communication Component version 2'.InMessage
StreamIn:
InStream
OutMsg:
Automation
'Navision Communication Component version 2'.OutMessage
StreamOut:
OutStream
Text:
Text size 1024
I have created a codeunit (code see below) and a form with a button. The OnPush trigger of the Button calls the function SendMSMQ() of the codeunit.
If I run the codeunit and I click the button in my form, an error message comes up:
The stream has returned a read error
I spent already one whole day to find out whats wrong, but I couldn't.
If I set the property WithEvents of CC2 to NO I can see the
message under Message queue tool of XP with the text Hello world in it. If I set it to yes again, the message seems to be collected from the event, because not visible anymore under the message queue manager of Windows XP.
I found out the error happens on execution of following line:
StreamIn.READTEXT(Text, MAXSTRLEN(Text));
Does anybody have an idea whats wrong?
Thanks a lot!
Here's the code of the codeunit:
OnRun() IF ISCLEAR(CC2) THEN CREATE(CC2); IF ISCLEAR(MQBus) THEN CREATE(MQBus); CC2.AddBusAdapter(MQBus,1); MQBus.OpenReceiveQueue('.\private$\navision',0,0); SendMSMQ() MQBus.OpenWriteQueue('.\private$\navision',0,0); OutMsg := CC2.CreateoutMessage('Message queue://'); StreamOut := OutMsg.GetStream(); StreamOut.WRITETEXT('Hello World'); OutMsg.Send(0); CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH") InMsg := InMessage; StreamIn := InMsg.GetStream(); StreamIn.READTEXT(Text, MAXSTRLEN(Text)); MESSAGE(Text); InMsg.CommitMessage();
Global vars:
MQBus:
Automation
'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter
CC2:
Automation
'Navision Communication Component version2'.CommunicationComponent
InMsg:
Automation
'Navision Communication Component version 2'.InMessage
StreamIn:
InStream
OutMsg:
Automation
'Navision Communication Component version 2'.OutMessage
StreamOut:
OutStream
Text:
Text size 1024
0
Comments
-
I don't know what you are accomplishing, other than trying to figure out how to use MSMQ.
To have a codeunit monitor the MSMQ, you need to change it to a single instance codeunit. What I would do is to have one single instance codeunit monitoring the MSMQ and handling the received messages. Then I'd program sending the message into the form, or in its own codeunit. I don't have much time right now, but when I have some more I'll post an example in here.0 -
Hello DenSter,
thanks for your reply, yes I am trying out and want to get familiar with MSMQ. If I send a message from a C++ application I get the same error!
Single instance is already set to YES otherwise I could not receive the message!
Sending the message using the function in the same codeunit as the MSMQ handling takes place is not the problem. I placed the whole code of the function SendMSMQ also in the form which containes the button but the same result!
My problem is really the error message:
The stream has returned a read error
The code I used in the event trigger comes from somewhere on the board here, so the code seems to work for other people.
Is there any way to trace this probblem more detailed? What does this error message mean? Is the stream empty oer wrong format or what?
Really tough, I cannot continue my project because of this error!
Any more ideas? Thanks!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions