|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
VB.NET Get Message |
« View previous topic :: View next topic » |
Author |
Message
|
pannonej |
Posted: Fri Oct 07, 2005 10:50 am Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
I am afraid I dont quite understand the question. My end goal is to use VB.NET code to get a message in XML from the queue. I have demonstrated that I can put and get a message from the command prompt. I have also demonstrated that I can PUT with VB.NET code. I need a code sample to GET an XML message. _________________ -Joe Pannone |
|
Back to top |
|
 |
PeterPotkay |
Posted: Sat Oct 08, 2005 9:04 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
PeterPotkay wrote: |
Post your code and let's see what the problem is.
|
Post the exact code you are running, the exact error you are getting. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
pannonej |
Posted: Sat Oct 08, 2005 9:26 am Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
I am trying to use the code in this thread. Please take a look. _________________ -Joe Pannone |
|
Back to top |
|
 |
EddieA |
Posted: Sun Oct 09, 2005 10:14 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
I am trying to use the code in this thread. Please take a look. |
The code provided is only a routine. Please post the code that calls that routine, so we can see the values you are passing to it.
Also, post the values you set for MQSERVER when you ran your amqsputc/amqsgetc command line tests.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
pannonej |
Posted: Mon Oct 10, 2005 2:46 am Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
Please Read the entire previous messages, I post the code and the values you ask for. _________________ -Joe Pannone |
|
Back to top |
|
 |
pannonej |
Posted: Mon Oct 10, 2005 3:04 am Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
To PUT a message I use the following code succesfully:
Public Function PutQueue(ByVal QM As String, ByVal QN As String, _
ByVal Msg As String, ByVal OpenOptions As Integer) As Integer
Dim mqQMgr As MQQueueManager '* MQQueueManager instance
Dim mqQueue As MQQueue '* MQQueue instance
Dim mqMsg As MQMessage '* MQMessage instance
Dim mqPutMsgOpts As MQPutMessageOptions '* MQPutMessageOptions instance
Dim msgLen As Integer '* Message length
'*
'* Try to create an MQQueueManager instance
'*
Try
'* queue name, queue manager name provided
mqQMgr = New MQQueueManager(QM)
Catch mqe As MQException
'* stop if failed
Console.WriteLine("Creation of MQQueueManager ended with " & mqe.Message)
Return (mqe.Reason)
End Try
'*
'* Try to open the queue
'*
Try
mqQueue = mqQMgr.AccessQueue(QN, OpenOptions) '* open queue for input but not if MQM stopping
Catch mqe As MQException
'* stop if failed
Console.WriteLine("MQQueueManager::AccessQueue ended with {0}", mqe.Message)
Return (mqe.Reason)
End Try
'*
'* Put to the message queue
'*
msgLen = Msg.Length
If (msgLen > 0) Then
Try
'* put the next message to the queue
mqMsg = New MQMessage
'03/21/2004 Begin
mqMsg.CharacterSet = 437 'ascii - default is 1200 which is unicode.
'03/21/2004 End
mqMsg.ReplyToQueueManagerName = "QM_CC_P1"
'mqMsg.ReplyToQueueName = "MYREPLY"
mqMsg.Format = MQC.MQFMT_STRING
mqMsg.WriteString(Msg)
mqQueue.Put(mqMsg) ', mqPutMsgOpts)
Catch mqe As MQException
'* report the error
Console.WriteLine("MQQueue::Put ended with {0}", mqe.Message)
Return (mqe.Reason)
End Try
End If
Return (0)
End Function
I pass the following in a button click:
Dim putretval
Dim strQM = "UTQM"
Dim strQ = "TDXR1.TESTQ"
Dim strLine = "Hello from Forza at 2:20pm"
PutRetVal = PutQueue(strQM, strQ, strLine, IBM.WMQ.MQC.MQOO_OUTPUT + IBM.WMQ.MQC.MQOO_SET_ALL_CONTEXT + IBM.WMQ.MQC.MQOO_FAIL_IF_QUIESCING)
_________________
From the connected server I can use the following command successfully:
amqsputc TDXR1.TESTQ UTQM
I am able to type in a string, and exit when I hit enter twice.
I then can type the following to retrieve the messages:
amqsgetc TDXR1.TESTQ UTQM _________________ -Joe Pannone |
|
Back to top |
|
 |
EddieA |
Posted: Mon Oct 10, 2005 10:57 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
Please Read the entire previous messages, I post the code and the values you ask for |
No, you haven't. I would suggest re-reading my question.
Quote: |
The code provided is only a routine. Please post the code that calls that routine, so we can see the values you are passing to it. |
Where have you provided this information.
Quote: |
post the values you set for MQSERVER when you ran your amqsputc/amqsgetc command line tests |
And this.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
pannonej |
Posted: Mon Oct 10, 2005 11:06 am Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
ok, sorry about that:
Dim putretval
Dim strQM = "UTQM"
Dim strQ = "TDXR1.TESTQ"
Dim strLine = "Hello from Forza at 2:20pm"
' PutRetVal = PutQueue(strQM, strQ, strLine, IBM.WMQ.MQC.MQOO_OUTPUT + IBM.WMQ.MQC.MQOO_SET_ALL_CONTEXT + IBM.WMQ.MQC.MQOO_FAIL_IF_QUIESCING)
putretval = GetQueue(strQM, strQ, "1414", "")
--------------------------
Public Function GetQueue(ByVal QM As String, ByVal QN As String, ByVal Channel As String, ByVal Conn As String) As Integer
Dim mqQMgr As MQQueueManager '* MQQueueManager instance
Dim mqQueue As MQQueue '* MQQueue instance
Dim queueName As String '* Name of queue to use
'*
'* Try to create an MQQueueManager instance
'*
' Try
' '* queue name, queue manager name provided
' mqQMgr = New MQQueueManager(QM, Channel, Conn)
' Catch mqe As MQException
' '* stop if failed
' TextBox1.Text = "Creation of MQQueueManager ended with " & mqe.Message
' Return (mqe.Reason)
' End Try
'*
'* Try to open the queue
'*
Try
mqQueue = mqQMgr.AccessQueue(QN, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING) '* open queue for input but not if MQM stopping
Catch mqe As MQException
'* stop if failed
TextBox1.Text = String.Format("MQQueueManager::AccessQueue ended with {0}", mqe.Message)
Return (mqe.Reason)
End Try
'*
'* Get messages from the message queue
'* Loop until there is a failure
'*
Dim isContinue As Boolean = True
Do While (isContinue = True)
Dim mqMsg As MQMessage '* MQMessage instance
Dim mqGetMsgOpts As MQGetMessageOptions '* MQGetMessageOptions instance
mqMsg = New MQMessage
mqGetMsgOpts = New MQGetMessageOptions
mqGetMsgOpts.WaitInterval = 15000 '* 15 second limit for waiting
Try
mqQueue.Get(mqMsg, mqGetMsgOpts)
If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then
TextBox1.Text = mqMsg.ReadString(mqMsg.MessageLength)
Else
TextBox1.Text = "Non-text message"
End If
Catch mqe As MQException
'* report reason, if any
If (mqe.Reason = MQC.MQRC_NO_MSG_AVAILABLE) Then
'* special report for normal end
TextBox1.Text = "no more messages"
isContinue = False
Else
'* general report for other reasons
TextBox1.Text = "MQQueue::Get ended with {0}" & mqe.Message
'* treat truncated message as a failure for this sample
If (mqe.Reason = MQC.MQRC_TRUNCATED_MSG_FAILED) Then
isContinue = False
End If
End If
End Try
Loop
Return (0)
End Function
------------------------------
From the connected server I can use the following command successfully from the command prompt:
amqsputc TDXR1.TESTQ UTQM
I am able to type in a string, and exit when I hit enter twice.
I then can type the following to retrieve the messages:
amqsgetc TDXR1.TESTQ UTQM _________________ -Joe Pannone |
|
Back to top |
|
 |
EddieA |
Posted: Mon Oct 10, 2005 11:34 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
putretval = GetQueue(strQM, strQ, "1414", "") |
Did you look at the parameters required by GetQueue:
Quote: |
Public Function GetQueue(ByVal QM As String, ByVal QN As String, ByVal Channel As String, ByVal Conn As String) As Integer |
So, you are passing in:
QM = UTQM
QN = TDXR1.TESTQ
Channel = 1414
Conn = "nothing"
So, you're passing in the wrong data. 1414 is the Conn value. You need a Channel as well, because that routine is set up as a Client connection. Use the same channel you used for MQSERVER when you did the amqsputc/amqsgetc tests.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
pannonej |
Posted: Mon Oct 10, 2005 2:00 pm Post subject: |
|
|
 Novice
Joined: 30 Sep 2005 Posts: 13
|
QM = UTQM
QN = TDXR1.TESTQ
Channel = M1150.CLIENT.KJFU567
Conn = ug04-242.unigroupinc.com(1415)
I'm not sure how you're developing your code, but remember, this channel
is defined to use SSL....so if you're going to not use the Channel Table that I sent
you...which is automatically set-up for SSL connections...and instead your going to use
your own config file, then be sure to take SSL into consideration when making your
MQ Connection to our system over the above channel.
---------------------
I get the folllowing error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. _________________ -Joe Pannone |
|
Back to top |
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|