Author |
Message
|
klamerus |
Posted: Sat Mar 26, 2005 8:31 pm Post subject: Just need another line or two |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Okay,
This is a working VB callback from a click on a form. NBD.
I just need to add whatever to make it work with a queue mgr that's on a different server (vs. my workstation).
Can anyone provide the missing statement(s)?
Private Sub Command1_Click()
Dim MQSess As MQSession
Dim QMgr As MQQueueManager
Dim Queue As MQQueue
Set MQSess = CreateObject("MQAX200.MQSession")
Set QMgr = MQSess.AccessQueueManager("Test1")
Set Queue = QMgr.AccessQueue("TestQueue1", MQOO_OUTPUT)
Set PutMsg = MQSess.AccessMessage()
PutMsgStr = "Boo"
PutMsg.MessageData = PutMsgStr
Set PutOptions = MQSess.AccessPutMessageOptions()
Queue.Put PutMsg, PutOptions
End Sub |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Mar 27, 2005 6:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Code: |
'******************************************************************'
'* Initialise the client channel definition if required *'
'******************************************************************'
MQCNOCD_DEFAULTS CNOCD ' MQCNO defaults
If chkUseClientChannelDefiniton.Value = 1 Then ' Checked ?
CNOCD.ChannelDef.ConnectionName = txtConnName.Text
CNOCD.ChannelDef.ChannelName = txtSvrconnChannelName.Text
CNOCD.ChannelDef.Version = MQCD_VERSION_6 ' Compatible 5.2.x
Else
CNOCD.ConnectOpts.Version = MQCNO_VERSION_1 ' No MQCD passed
End If
'******************************************************************'
'* Connect to queue manager *'
'******************************************************************'
QmgrNameIn = txtQMgrName.Text ' Use fixed length
MQCONNXAny QmgrNameIn, CNOCD, Hcon, CompCode, Reason |
From amqscnxb.frm in amqscnxb.vbp in <MQ_Install>/Tools/VB/sampVB6. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
klamerus |
Posted: Sun Mar 27, 2005 7:28 am Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
VB doesn't appear to like adding
MQCNOCD_DEFAULTS CNOCD
to the above program at all. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Mar 27, 2005 7:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well.
You may have a bit of a sticky wicket.
The code I showed you, again from a sample program that is probably on your machine, uses the straight mappings to the MQ API calls, not the ActiveX COM interface.
The only way I know to use a client connection from the ActiveX interface is to use an MQSERVER or the client connection table Environment variables.
Which doesn't help when you need to make more than one client connection from the same program. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
klamerus |
Posted: Sun Mar 27, 2005 8:16 am Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Well, we all love to hate windows (or VB anyway).
It basically appears that there are 2-3 different ways of dealing with this stuff. The APIs and ActiveX/COM (and maybe shortly .Net).
It's very frustrating. I would imagine that all the options are open with the API, and I suppose I could wrap these in a COM object so that I can use this from a web page (which is the goal in the end). I was hoping to prototype with VB on my desktop (using ActiveX/COM) and then move the working stuff up to a server.
Not that you've done this, but any first thoughts on why using the APIs inside of a component (to avoid playing with the environment) wouldn't work? |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Mar 27, 2005 8:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Just see if you can run the sample I pointed you at. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
klamerus |
Posted: Sun Mar 27, 2005 8:39 am Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Didn't have any luck with it, but probably need to do some more playing with it.
I did find the MQAX samples in the install. They do let me specify the queue manager and queues (for local queues). I'm wondering if there's a syntax for remote that I can use with it. I saw a remote specification for the Java classes that looks like a combo of the IP address (or name of the remote system) some slashing with channels, etc. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Mar 27, 2005 12:13 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, yeah. If you don't understand what a connection name looks like, you might have some difficulty using one.
An MQServer environment variable is built in the following manner:
<channel name>/<protocol>/<connection name>.
A typical (these days) MQSERVER variable might be "SYSTEM.DEF.SVRCONN/TCP/host.domain.com".
An equally typical MQSERVER variable might be "SYSTEM.DEF.SVRCONN/TCP/host.domain.com(1415)".
Connection names are built as <hostname>(<listener port>). Unless the listener port is 1414, in which case you don't need the parentheses or the port number. But it works if you put them in. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
klamerus |
Posted: Sun Mar 27, 2005 3:34 pm Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
That's not exactly what I meant. I've seen that syntax before, but I haven't seen it used when trying to connect to a queue manager. That's what I meant. I don't think I can get by with an environment variable because I need to have several connections open at once. Actually several queue managers. We want to show the status of queues on 3 different servers (our production systems). I'm thinking I may have to use the API, and if I need to use it from VBScript (for the web page), I'll need to wrap a COM/ActiveX component around it. If I can that is. |
|
Back to top |
|
 |
klamerus |
Posted: Sun Mar 27, 2005 3:45 pm Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
Anyway, I tried the original VB sample and I get a 2059 error, or I get a 2059 if I say to not use client channel defs. |
|
Back to top |
|
 |
kevinf2349 |
Posted: Mon Mar 28, 2005 6:11 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
If you are using VB.Net you can always set the environment up like this
Code: |
MQEnvironment.Hostname = "Server1(1415)"
MQEnvironment.Channel = "ChannelName" |
That works like a charm for me and I connect to 30 servers this way.
Hope this helps. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Mar 28, 2005 9:39 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
All,
I thought if you installed MQ Server on a PC with VB then all VB interactions with MQ would be in bindings mode. If you wanted to do client mode then you had to set an environment (i.e. AMQ_ or MQ_) to allow it.
Secondly, I'm surprised this worked:
Code: |
MQEnvironment.Hostname = "Server1(1415)"
MQEnvironment.Channel = "ChannelName" |
For Java, you do the following:
Code: |
MQEnvironment.hostname = "Server1";
MQEnvironment.port = 1415;
MQEnvironment.channel = "ChannelName"; |
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
kevinf2349 |
Posted: Mon Mar 28, 2005 10:12 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Roger
The snippet I posted was for VB.Net and it works like a champ. I wasn't too sure that it was what he wanted but I thought I would throw it out there just in case.  |
|
Back to top |
|
 |
klamerus |
Posted: Thu Apr 07, 2005 2:22 am Post subject: |
|
|
 Disciple
Joined: 05 Jul 2004 Posts: 199 Location: Detroit, MI
|
That's exactly what I wanted.
Sorry for the delayed response, but I was in vacation for a week in Rome (lucky me). I'm at home now, but I'll be trying this ASAP in my work setting. |
|
Back to top |
|
 |
|