ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » simple sample code using vb.net

Post new topic  Reply to topic
 simple sample code using vb.net « View previous topic :: View next topic » 
Author Message
mtaylor314
PostPosted: Thu Sep 21, 2006 9:51 am    Post subject: simple sample code using vb.net Reply with quote

Newbie

Joined: 19 Sep 2006
Posts: 9

I am running MQSeries v5.3 on XP. I will be in the near future writing a program (not simple) using vb.net. Does anybody know anywhere on the web I can view a sample code or does anybody have one I can cut and paste into .net? The only things I can find online is information telling me I can use it, but nothing about it. I have figured out so far the term imports IBM.WMQ and that does reference the file. I just need some code to help me out some more. Anything will help greatly, thank you in advance.
Back to top
View user's profile Send private message AIM Address
jefflowrey
PostPosted: Thu Sep 21, 2006 10:24 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you have installed MQ on your machine, and you have installed the development kit option, then you have <mq_install>/Tools/dotnet/samples.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mtaylor314
PostPosted: Thu Sep 21, 2006 12:32 pm    Post subject: Reply with quote

Newbie

Joined: 19 Sep 2006
Posts: 9

thanks for that, I found those files and trying to compile. I am getting a error 2059. Any way of getting that figured out. IBM says it is Microsoft's fault. And Microsoft's help doesn't correct the problem.
Back to top
View user's profile Send private message AIM Address
mvic
PostPosted: Thu Sep 21, 2006 12:50 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

mtaylor314 wrote:
thanks for that, I found those files and trying to compile. I am getting a error 2059.

I guess you must have compiled (an .exe program?) and are now running the program?
Quote:
Any way of getting that figured out. IBM says it is Microsoft's fault. And Microsoft's help doesn't correct the problem.

Did you provide fuller details than these to your IBM rep? I'm surprised anyone could reach a conclusion with only the above details.

2059 means the app can't connect to the queue manager named in your program. So the first step would be to describe in this forum all the inputs you're providing when attempting to make the connection. A code snippet and details of inputs would help.

We want to help... we just need the correct details. Thanks!
Back to top
View user's profile Send private message
mtaylor314
PostPosted: Thu Sep 21, 2006 1:14 pm    Post subject: Reply with quote

Newbie

Joined: 19 Sep 2006
Posts: 9

This is the sample code given with the v5.3 download for vb.net.

Imports System
Imports IBM.WMQ

Module module1

Sub Main(ByVal CmdArgs() As String)

Dim mqQMgr As MQQueueManager '* MQQueueManager instance
Dim mqQueue As MQQueue '* MQQueue instance
Dim queueName As String '* Name of queue to use

System.Console.WriteLine("Sample VMQSGET start")
If (CmdArgs.Length = 0) Then
System.Console.WriteLine("Required parameter missing - queue name")
End
Else
queueName = CmdArgs.GetValue(0)
End If

'*
'* Try to create an MQQueueManager instance
'*
Try
If (CmdArgs.Length > 2) Then
'* queue name, queue manager name, channel definition all provided

'* Break down the channel definition,
'* which is of the form "channel-name/transport-type/connection-name".
Dim channelDefinition As String = CmdArgs.GetValue(2)
Dim channelName As String
Dim transportType As String
Dim connectionName As String
Dim separator As Char() = "/"
Dim parts As String()

parts = channelDefinition.Split(separator)
If (parts.Length > 0) Then
channelName = parts(0)
End If
If (parts.Length > 1) Then
transportType = parts(1)
End If
If (parts.Length > 2) Then
connectionName = parts(2)
End If
mqQMgr = New MQQueueManager(CmdArgs.GetValue(1), channelName, connectionName)
Else
If (CmdArgs.Length = 2) Then
'* queue name, queue manager name provided
mqQMgr = New MQQueueManager(CmdArgs.GetValue(1))
Else
'* queue name provided - use default queue manager
mqQMgr = New MQQueueManager
End If
End If
Catch mqe As IBM.WMQ.MQException
'* stop if failed
System.Console.WriteLine("create of MQQueueManager ended with {0}", mqe.Message)
End
End Try


'*
'* Try to open the queue
'*
Try
mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING) '* open queue for input but not if MQM stopping
Catch mqe As IBM.WMQ.MQException
'* stop if failed
System.Console.WriteLine("MQQueueManager::AccessQueue ended with {0}", mqe.Message)
End
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
mqGetMsgOpts.Options = mqGetMsgOpts.Options Or MQC.MQGMO_WAIT
Try
mqQueue.Get(mqMsg, mqGetMsgOpts)
If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then
System.Console.WriteLine(mqMsg.ReadString(mqMsg.MessageLength))
Else
System.Console.WriteLine("Non-text message")
End If
Catch mqe As IBM.WMQ.MQException
'* report reason, if any
If (mqe.Reason = MQC.MQRC_NO_MSG_AVAILABLE) Then
'* special report for normal end
System.Console.WriteLine("no more messages")
isContinue = False
Else
'* general report for other reasons
System.Console.WriteLine("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

System.Console.WriteLine("Sample VMQSGET end")
System.Console.ReadLine()
End

End Sub

End Module

after compiling and running the .exe is when I find the error 2059. I use QUEUE1 as the queue name and queue.manager.1 as the default queue manager. If you need to know anything else just let me know. Sorry if this is not enough info, but if you need more just let me know. I do appreciate the help.
Back to top
View user's profile Send private message AIM Address
mvic
PostPosted: Thu Sep 21, 2006 1:20 pm    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

mtaylor314 wrote:
after compiling and running the .exe is when I find the error 2059. I use QUEUE1 as the queue name and queue.manager.1 as the default queue manager. If you need to know anything else just let me know. Sorry if this is not enough info, but if you need more just let me know. I do appreciate the help.

A couple of things to check:
1. is the queue manager started?
2. what is the exact command line that is used to start the app?
3. is the queue manager on the same machine? - if not, then is a firewall preventing the connection perhaps?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 21, 2006 2:08 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Is the name of the queue manager really "queue.manager.1"?

Maybe you need to address it as "QUEUE.MANAGER.1", or 'queue.manager.1'.

Queue manager names are case sensitive, I think.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mtaylor314
PostPosted: Fri Sep 22, 2006 4:47 am    Post subject: Reply with quote

Newbie

Joined: 19 Sep 2006
Posts: 9

thank you guys for all of your help, it was the queue manager needed started. Once I started that then it did what it was supposed to.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » simple sample code using vb.net
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.