|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Need Guru fast - put message to Websphere MQ using vb.net |
« View previous topic :: View next topic » |
Author |
Message
|
jsena |
Posted: Fri Feb 23, 2007 12:48 pm Post subject: Need Guru fast - put message to Websphere MQ using vb.net |
|
|
Newbie
Joined: 23 Feb 2007 Posts: 5
|
Hello,
I have a very big problem in that not only am I new to MQ and vb.net but I’m also stupid, as I’ll no doubt prove in a minute. I need to get an xml document onto a queue. I am using WebSphere MQ 6.0 and Microsoft Visual Studio 2005 (vb.net). In my Windows Application project, which is where I would like the code to be, I added a reference to amqmdnet.dll, added the Imports IBM.WMQ statement and added the following sub which I’ve pieced together from a lot of other posts:
Code: |
Private Sub SendMessage_Click()
MQEnvironment.Hostname = "Q_CHANNEL_TEST/TCP/164.156.128.1(1417)"
MQEnvironment.Channel = "Q_CHANNEL_TEST"
Dim mqQMgr As MQQueueManager = New MQQueueManager("Q_MANAGER_TEST")
Dim mqQueue As MQQueue = mqQMgr.AccessQueue("Q_LOCAL_TEST", MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_OUTPUT)
Dim mqMsg As MQMessage = New MQMessage
Dim PutMsgStr As String
Dim sr As StreamReader = File.OpenText("C:/Upload.xml")
mqMsg.Persistence = MQC.MQPER_NOT_PERSISTENT
mqMsg.Format = MQC.MQFMT_STRING
PutMsgStr = sr.ReadToEnd
sr.Close()
mqMsg.WriteString(PutMsgStr)
Dim mqPutMsgOpts As MQPutMessageOptions = New MQPutMessageOptions
mqQueue.Put(mqMsg, mqPutMsgOpts)
mqQueue.Close()
mqQMgr.Disconnect()
End Sub
|
I end up with the following error:
Code: |
IBM.WMQ.MQException was caught
Message="Error in the application."
Source="amqmdnet"
StackTrace:
at IBM.WMQ.MQQueueManager.Connect(String queueManagerName)
at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, String Channel, String ConnName)
at WritingXml.Form1. SendMessage_Click() in C:\Documents and Settings\JSena \WritingXml\ Form1.vb:line 504
|
at the following line:
Code: |
Dim mqQMgr As MQQueueManager = New MQQueueManager("Q_MANAGER_TEST")
|
So then I tried creating a Consol Application project, added a reference to amqmdnet.dll, and pasted in the code from the vmqsput.vb sample that was in Tools\dotnet\samples\vb\ and got it to compile after some minor adjustments but then I ended up with the same error at the same line. What is the deal? Any help would be very much appreciated.
jordan |
|
Back to top |
|
 |
vennela |
Posted: Fri Feb 23, 2007 1:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Quote: |
MQEnvironment.Hostname = "Q_CHANNEL_TEST/TCP/164.156.128.1(1417)" |
Usually this should be just hostname
Coming from a java background, it should have things like
MQEnvironment.hostname = "ipaddress"
MQEnvironment.portno = listener port
MQEnvironment.channel = "SVRCONN channel name" |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Feb 23, 2007 6:21 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Your best bet is to not specify the qmgr name at all.
other than that, vennela is correct. MQEnvironment.hostname should *only* be the ipaddress or hostname of the machine.
In your case, it should be "164.156.128.1".
Channel would be "Q_CHANNEL_TEST", and port would be '1417'. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
ashu |
Posted: Mon Feb 26, 2007 12:43 am Post subject: |
|
|
 Centurion
Joined: 11 Nov 2006 Posts: 132
|
Quote: |
MQEnvironment.Hostname = "Q_CHANNEL_TEST/TCP/164.156.128.1(1417)"
MQEnvironment.Channel = "Q_CHANNEL_TEST" |
If the MQ server is installed on the same machine as the appln and if you are using Server Conn and Client Conn channel types then you need not specify Hostname,It should solve your problem.
On the other hand if you are using message channes directly in your code then hostname is not required since this itself proves that client appln and MQ server are on the same machine....
How is "Q_CHANNEL_TEST" declared ? |
|
Back to top |
|
 |
jsena |
Posted: Mon Feb 26, 2007 8:10 am Post subject: Thank you |
|
|
Newbie
Joined: 23 Feb 2007 Posts: 5
|
Thank you all very much, it works great now!!!
jordan |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|