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 » question for running a vb.net MQ example

Post new topic  Reply to topic
 question for running a vb.net MQ example « View previous topic :: View next topic » 
Author Message
Agent MQ
PostPosted: Tue Oct 14, 2003 8:53 am    Post subject: question for running a vb.net MQ example Reply with quote

Novice

Joined: 04 Apr 2003
Posts: 19

i have installed the mqseries .net support pac and it created a folder(dotnet) within tools with some sample programs. I do have visual studio.net installed with mq5.3 also.

I am very new to this, how do I take one of the vb.net samples VMQSPUT.vb and compile it with visual studio.net ???

I would apprecaite any help, as I have never used these before. When I created just a new project(console app) cut and pasted the sample in, I clicked add refrence and pointed to amqmdnet.dll. It says 'sub main' was not found...

here is the sample:
Code:

'* Library:       WebSphere MQ
'* Component:     MQ.NET Sample Programs
'* Part:          VMQSPUT.VB
'*
'* Description:   Sample Visual Basic program that puts messages to a named
'*                queue.
'*
'*                VMQSPUT has 3 parameters:
'*                - the name of a queue (required)
'*                - the name of a queue manager (optional)
'*                - the definition of a channel (optional)
'*
'*                If no queue manager name is given, the queue manager
'*                defaults to the default local queue manager. If a
'*                channel is defined, it should have the same format
'*                as the MQSERVER environment variable.
'*  <START_COPYRIGHT>
'*  Licensed Materials - Property of IBM
'*                   
'*  5724-B41         
'*  (C) Copyright IBM Corp. 1994, 2003 All Rights Reserved.
'*                   
'*  US Government Users Restricted Rights - Use, duplication or
'*  disclosure restricted by GSA ADP Schedule Contract with
'*  IBM Corp.       
'*  <END_COPYRIGHT>

Imports System
Imports IBM.WMQ

Module vmqsput

    Function Main(ByVal CmdArgs() As String) 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 queueName As String                 '* Name of queue to use
        Dim msgLen As Integer                   '* Message length
        Dim message As String                   '* Message buffer

        System.Console.WriteLine("Sample VMQSPUT start")
        If (CmdArgs.Length = 0) Then
            System.Console.WriteLine("Required parameter missing - queue name")
            Return (99)
        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 MQException
            '* stop if failed
            System.Console.WriteLine("create of MQQueueManager ended with {0}", mqe.Message)
            Return (mqe.Reason)
        End Try


        '*
        '* Try to open the queue
        '*
        Try
            mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING)     '* open queue for output but not if MQM stopping
        Catch mqe As MQException
            '* stop if failed
            System.Console.WriteLine("MQQueueManager::AccessQueue ended with {0}", mqe.Message)
            Return (mqe.Reason)
        End Try

        '*
        '* Read lines from the console and put them to the message queue
        '* Loop until end of input, or there is a failure
        '*
        Dim isContinue As Boolean = True
        Do While (isContinue = True)
            message = System.Console.ReadLine()
            msgLen = message.Length

            If (msgLen > 0) Then
                '* put the next message to the queue
                mqMsg = New MQMessage()
                mqMsg.WriteString(message)
                mqMsg.Format = MQC.MQFMT_STRING
                mqPutMsgOpts = New MQPutMessageOptions()
                Try
                    mqQueue.Put(mqMsg, mqPutMsgOpts)
                Catch mqe As MQException
                    '* report the error
                    System.Console.WriteLine("MQQueue::Put ended with {0}", mqe.Message)
                End Try
            Else
                '* quit loop when empty line is read
                isContinue = False
            End If
        Loop

        System.Console.WriteLine("Sample VMQSPUT end")
        Return (0)

    End Function

End Module


how do I fix this??



thank you kindly[/code]
Back to top
View user's profile Send private message
dpchiesa
PostPosted: Tue Oct 21, 2003 11:31 am    Post subject: How to compile? Reply with quote

Apprentice

Joined: 29 May 2002
Posts: 46

If you look in C:\Program Files\IBM\MQ\Tools\dotnet\samples\vb you will see a batch file that includes working commands to compile the vb.net code from the command line. Using Visual Studio is a bit more complicated: you need to create a new project, probably a console app, then paste in the code you have, add the reference to amqmdnet.dll, and then F5. The steps may be a bit more involved than that, but you get the idea.

Also I suggest you get the latest CSD05 for WMQ5.3 - it includes supported .NET classes for MQ.

http://www-3.ibm.com/software/integration/mqfamily/support/summary/wnt.html
_________________
-dpchiesa
Back to top
View user's profile Send private message
Agent MQ
PostPosted: Fri Oct 24, 2003 11:45 am    Post subject: Reply with quote

Novice

Joined: 04 Apr 2003
Posts: 19

thanks alot.

I have another question for you. We have been waiting for this csd5 to come out and now that it has we are unsure what we should do..

our options are:

1- it is too late in our testing cycle to apply this csd to our xp/mq5.3 machines so we will have to send it out as it is( it has no csd's at all) Then later, send out this csd5 in a transmittal after it is in production..

or

2 - stop testing. update our official loads to include this csd5 and start testing all over again...

what is your recommendation??

thanks
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri Oct 24, 2003 8:36 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Tough call - take the pain now or take the pain later.

Since you have not yet implemented the code in your production environment, I would take the pain now. Currently, you have everyone involved (developers, testers, etc..). Therefore, any issues can be resolved quickly.

That's my 2 cents.

later
Roger...
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Agent MQ
PostPosted: Mon Nov 03, 2003 10:09 am    Post subject: Reply with quote

Novice

Joined: 04 Apr 2003
Posts: 19

cool, i got it working correctly... my first .net experience. I have a newbie question I found an example by neil kolban :

Example how to create and write a RFH2 header to MQSeries. This example uses the MQSeries.NET package

what is a RFH2 header? what is it for? how do i use it?

thanks!
Back to top
View user's profile Send private message
vijkid
PostPosted: Fri Nov 07, 2003 3:32 am    Post subject: Problem with MQGET Reply with quote

Novice

Joined: 09 Oct 2003
Posts: 13

Dear All,

I have used MQ in asp.net and I am able to post message sucessfully, but the problem here is when I fetch the message after the execution is put resets my IIS application and everytime my application_onstart fires. Can anyone tell me what cdan be the possible reasons for loosing session variable and application reset

Kindly help

Vijay
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » question for running a vb.net MQ example
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.