|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQSERVER |
« View previous topic :: View next topic » |
Author |
Message
|
rajaramanl |
Posted: Thu Jan 02, 2003 8:05 pm Post subject: MQSERVER |
|
|
Novice
Joined: 07 Apr 2002 Posts: 13 Location: India
|
Hi,
I connect to MQServer using Visual Basic. I have two applications running on the same server and both connect to different MQ Servers. MQSERVER variable value has to be changed accordingly to connect to respectinve servers.
Is there any way to change this MQSERVER variable value dynamically. or to handle this situation in Visual Basic so that both applications connect to their respective MQ Servers wihout any problem.
thanks in advance.
Rajaram |
|
Back to top |
|
 |
mqonnet |
Posted: Fri Jan 03, 2003 6:05 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
You cannot change MQSERVER value dynamically.
The alternative to this and solution to your issue is to use, MQCONNX and specify the respective connection names in the two apps to connect to two different qms.
Cheers.
Kumar _________________ IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator |
|
Back to top |
|
 |
rajaramanl |
Posted: Sat Jan 04, 2003 3:55 am Post subject: MQSERVER |
|
|
Novice
Joined: 07 Apr 2002 Posts: 13 Location: India
|
Kumar,
Can u please tell me know how to use MQCONNX method in Visual Basic. i user MQSession.AccessQueueManager(QueueManager) to connect to MQ Queue Manager
thanks,
rajaram |
|
Back to top |
|
 |
mqonnet |
Posted: Mon Jan 06, 2003 5:36 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
You use MQCONNX the same way you use MQCONN in your program. The only difference in the two being MQCNO, Connect Options structure that you have to define and set values for. This is the structure that would have your connection name and other stuff.
Refer to "App programming reference" guide for more info on MQCONNX.
As for using it in VB is concerned. The invocation is no different than any other platforms.
Cheers.
Kumar _________________ IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator |
|
Back to top |
|
 |
alouie |
Posted: Tue Jan 14, 2003 6:12 am Post subject: MQSERVER |
|
|
Newbie
Joined: 31 May 2001 Posts: 5 Location: Guardian Life Insurance Company
|
It is possible to change the MQSERVER variable value dynamically using Windows API calls. However the change will not affect the currently running application as it's environment block will not be refreshed.
The way I worked around this was to develop my application is 2 pieces. The driver piece set the MQSERVER variable and then used the Windows API CreateProcess call to start the second piece. The new process will start with the updated environment block.
Here is the code to change MQSERVER:
Private Sub setMQSERVER(myConnectionName As String)
Dim strEnvVarValue As String * 48
Dim hKey As Long ' receives handle to the registry key
Dim secattr As SECURITY_ATTRIBUTES ' security settings for the key
Dim subkey As String ' name of the subkey to create or open
Dim neworused As Long ' receives flag for if the key was created or opened
Dim stringbuffer As String ' the string to put into the registry
Dim retval As Long ' return value
Dim success As Long
' Set the name of the new key and the default security settings
subkey = "System\CurrentControlSet\Control\Session Manager\Environment"
secattr.nLength = Len(secattr)
secattr.lpSecurityDescriptor = 0
secattr.bInheritHandle = 1
' Create (or open) the registry key.
retval = RegCreateKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, "", 0, KEY_WRITE, _
secattr, hKey, neworused)
If retval <> 0 Then
Debug.Print "Error opening or creating registry key -- aborting."
Exit Sub
End If
' Write the string to the registry. Note the use of ByVal in the second-to-last
' parameter because we are passing a string.
stringbuffer = txtQmgr & "/TCP/" & myConnectionName & _
"(" & txtPort & ")" & vbNullChar ' the terminating null is necessary
retval = RegSetValueEx(hKey, "MQSERVER", 0, REG_SZ, ByVal stringbuffer, _
Len(stringbuffer))
' Close the registry key.
retval = RegCloseKey(hKey)
retval = RegFlushKey(hKey)
retval = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, _
0&, _
"Environment", SMTO_ABORTIFHUNG, _
10000&, success)
' Set environment variable.
retval = SetEnvironmentVariable("MQSERVER", stringbuffer)
End Sub
Hope this helps. If you need more info, let me know.
Anthony |
|
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
|
|
|
|