Author |
Message
|
mani_sai |
Posted: Wed Oct 11, 2006 6:03 am Post subject: Programming Websphere MQ using ActiveX (mqax200.dll) |
|
|
Newbie
Joined: 11 Oct 2006 Posts: 5
|
Hello Experts,
I am programing using Websphere MQ ActiveX VB control (mqax200.dll).
I was succesfull in posting message to local queue.
I want to know to how to program by passing message from my localmachine to remote queue.
Remote Queue Details:
IPAddress: 164.156.54.56
Channel Name:S_Channel99
Port:1417
QueueManager Name: QM_Welcome99
QueueName: Q_Welcome99
Here is my VB code:
Can some one give me suggestions to modify my below code:
------------------------------------------------
Option Explicit
Private Sub cmdSendMessage_Click()
Dim MQSess As MQSession '* session object
Dim QMgr As MQQueueManager '* queue manager object
Dim Queue As MQQueue '* queue object
Dim PutMsg As MQMessage '* message object for put
Dim PutOptions As MQPutMessageOptions '* get message option
Dim PutMsgStr As String '* put message data string
Const FilePath = "C:/IESFileDataConversionXML/SendOutputFile/INTF_0439B.xml"
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
On Error GoTo HandleError
Set MQSess = New MQSession
Set QMgr = MQSess.AccessQueueManager("QM_infotechd99")
Set Queue = QMgr.AccessQueue("PCManiQueue", MQOO_OUTPUT Or MQOO_SET_IDENTITY_CONTEXT Or MQOO_INPUT_AS_Q_DEF)
Set PutMsg = MQSess.AccessMessage()
Dim FSO, TextStream
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(FilePath) Then
Set TextStream = FSO.OpenTextFile(FilePath, ForReading, False, _
TristateUseDefault)
' Read file in one hit
PutMsgStr = TextStream.ReadAll
TextStream.Close
Set TextStream = Nothing
End If
Set FSO = Nothing
PutMsg.MessageData = PutMsgStr
PutMsg.ApplicationIdData = "INTF_0439B"
Set PutOptions = MQSess.AccessPutMessageOptions()
PutOptions.Options = PutOptions.Options Or MQPMO_NO_SYNCPOINT Or MQPMO_SET_IDENTITY_CONTEXT
Queue.Put PutMsg, PutOptions
HandleError:
Dim ErrMsg As String
Dim StrPos As Integer
Cls
BackColor = RGB(255, 0, 0) '* set to red for error
Print "An error occurred as follows:"
Print ""
If MQSess.CompletionCode <> MQCC_OK Then
ErrMsg = Err.Description
StrPos = InStr(ErrMsg, " ") ' * search for first blank
If StrPos > 0 Then
Print Left(ErrMsg, StrPos) '* print offending MQAX object name
Else
Print Error(Err) '* print complete error object
End If
Print ""
Print "WebSphere MQ Completion Code = " & MQSess.CompletionCode
Print "WebSphere MQ Reason Code = " & MQSess.ReasonCode
Print "(" & MQSess.ReasonName & ")"
Else
Print "Visual Basic error: " & Err
Print Error(Err)
End If
Exit Sub
End Sub
------------------------------------------------------
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 11, 2006 6:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Have you tried using a remote queue definition rather than a local queue definition?
Note that remote queues cannot be opened for input & an error will result if MQOO_INPUT_etc is specified. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mani_sai |
Posted: Wed Oct 11, 2006 7:13 am Post subject: Thanks |
|
|
Newbie
Joined: 11 Oct 2006 Posts: 5
|
No, i have not tried that.
I need some sample VB code for doing that, can you point me some article
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 11, 2006 7:17 am Post subject: Re: Thanks |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mani_sai wrote: |
No, i have not tried that.
I need some sample VB code for doing that, can you point me some article
Thanks |
You're looking at it - I'm suggesting you change the local queue referred to in your code to a remote one!
Or if you're looking to connect your program directly to this remote queue manager (and therefore continue to put as if local) simply change the MQSession settings to establish a connection to this queue manager rather than the one you're currently using. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mani_sai |
Posted: Wed Oct 11, 2006 7:26 am Post subject: |
|
|
Newbie
Joined: 11 Oct 2006 Posts: 5
|
I can change the Queuename and Queuemanager name in my code.
do i need specify
IPAddress: 164.156.54.56
Channel Name:S_Channel99
Port:1417
to connect to the remote queue? If yes, where do i specify?
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 11, 2006 7:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
You don't connect to a remote queue, or any queue - you connect to a queue manager which can be local or remote. If you're currently using the client method to establish the session, replace the settings for your local queue manager with those for the remote one. If you're selecting server settings you need to switch to the client or establish a remote queue definition on your local manager.
All this is ablely laid out in the documentation....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mani_sai |
Posted: Wed Oct 11, 2006 7:52 am Post subject: |
|
|
Newbie
Joined: 11 Oct 2006 Posts: 5
|
Thanks for your reply. Sorry i am not explaning you properly about my requirement.
You are talking about configuring the remote queue manager using Websphere MQ explorer. and then using the remote queue details in my vb code.
The above needs a websphere MQ client on the machine.
My requirement is i dont have Websphere MQ client installed on my machine where i am running the vb component.
I am going to run this vb component on a client machine which dont have Websphere MQ client. so how to program in that case.
I know we can program using .net interface, but i need to program using vb interface.
Thanks |
|
Back to top |
|
 |
mani_sai |
Posted: Wed Oct 11, 2006 7:55 am Post subject: |
|
|
Newbie
Joined: 11 Oct 2006 Posts: 5
|
For example:
We can specify remote queue server details in the code itself in .net like this:
------------------------------------------------------------------
const string connectionType = MQC.TRANSPORT_MQSERIES_CLIENT;
// Define the name of the queue manager to use (applies to all connections)
const string qManager = "QM_infotechd99";
// Define the name of your host connection (applies to client connections only)
const string hostName = "164.156.94.92";
// Define the name of the channel to use (applies to client connections only)
const string channel = "S_infotechd99";
//const int port = 1417;
/// <summary>
/// Initialise the connection properties for the connection type requested
/// </summary>
/// <param name="connectionType">One of the MQC.TRANSPORT_MQSERIES_ values</param>
static Hashtable init(String connectionType)
{
Hashtable connectionProperties = new Hashtable();
// Add the connection type
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType);
// Set up the rest of the connection properties, based on the
// connection type requested
switch(connectionType)
{
case MQC.TRANSPORT_MQSERIES_BINDINGS:
break;
case MQC.TRANSPORT_MQSERIES_CLIENT:
//connectionProperties.Add(MQC.USER_ID_PROPERTY , UserID);
//connectionProperties.Add(MQC.PASSWORD_PROPERTY, Password);
connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName);
//connectionProperties.Add(MQC.PORT_PROPERTY, port);
connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel);
break;
}
return connectionProperties;
----------------------------------------------------
but i want to program the above using VB 6.0 where i can specify IPaddress/Channel/Port in the code itself?
Is it possible?
Thanks |
|
Back to top |
|
 |
kevinf2349 |
Posted: Wed Oct 11, 2006 7:59 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
You will need the MQ client on the machine on which the application code is to run in order to do any MQ calls. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 11, 2006 11:05 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mani_sai wrote: |
I know we can program using .net interface, but i need to program using vb interface.
|
AFAIK both the VB & .NET interfaces require a client installation under them  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 12, 2006 1:25 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
VB6 is no longer supported. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 12, 2006 1:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jefflowrey wrote: |
VB6 is no longer supported. |
Yes, but when it was & if you're still using it (in an unsupported way) it required a client install. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|