Author |
Message
|
muthu_tek |
Posted: Tue Jul 20, 2010 9:10 pm Post subject: mqsicreatebroker command calling from java |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Dear All,
I have created .bat file for mqsicreatebroker command ,Program is getting struck When I call this bat file from java class.
create_broker.bat
Code: |
@ECHO ON
call "C:\Program Files\IBM\MQSI\6.1\bin\mqsiprofile.cmd"
ECHO "For broker"
mqsicreatedb.exe testdb -i muthu -a mypassword -u db2admin
ECHO "For DB created"
ECHO "For Broker start"
mqsicreatebroker.exe NewBroker -i muthu -a mypassword -q testqmgrNew -n testdb
ECHO "For Broker created"
EXIT |
Note:
I used mq commands in bat file and I called from java.It was executes properly.
Last edited by muthu_tek on Tue Jul 20, 2010 9:33 pm; edited 1 time in total |
|
Back to top |
|
 |
muthu_tek |
Posted: Tue Jul 20, 2010 9:31 pm Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
CallingBatchFile .java
Code: |
public class CallingBatchFile {
public static void main(String[] args) throws FileNotFoundException {
try {
Process p = Runtime.getRuntime().execute("D:\\create_broker.bat");
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
FileOutputStream fin = new FileOutputStream("createbrokerlog.txt");
String line;
while ((line=br.readLine()) != null) {
System.out.println("==================>>"+line);
}
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
} |
Note:
If I use ' Runtime.getRuntime().exec("") ' inside this [code] editor I am getting 'Service Temporarily Unavailable ' problem.
So I have used as ' Runtime.getRuntime().execute("") '" for editor convenience.
Any Help Guys ?
Thanks and Regards,
Marimuthu Udayakumar
Last edited by muthu_tek on Wed Jul 21, 2010 3:54 am; edited 1 time in total |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Jul 20, 2010 11:21 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Why on earth do you want to create a broker from within a Java App?
Brokers (once created) are pretty long lived things. Sorta like Databases.
A shell or .bat script is generally all that people need. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
muthu_tek |
Posted: Tue Jul 20, 2010 11:42 pm Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Quote: |
Why on earth do you want to create a broker from within a Java App?
|
I want to get input dynamically [QueueManagerName,BrokerName,ConfigurationManagerName..etc] from user using Java User Interface . |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 21, 2010 2:55 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The solution is immediately obvious from the errors you have posted. |
|
Back to top |
|
 |
muthu_tek |
Posted: Wed Jul 21, 2010 3:49 am Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Quote: |
The solution is immediately obvious from the errors you have posted. |
I used correct method call " Runtime.getRuntime().exec("") " only in program... this [Code] editor is not supporting "Runtime.getRuntime().exec("")" .So I used "Runtime.getRuntime().execute("")" here. |
|
Back to top |
|
 |
muthu_tek |
Posted: Wed Jul 21, 2010 4:04 am Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Any Help ?  |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jul 21, 2010 4:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
muthu_tek wrote: |
Quote: |
Why on earth do you want to create a broker from within a Java App?
|
I want to get input dynamically [QueueManagerName,BrokerName,ConfigurationManagerName..etc] from user using Java User Interface . |
Again why? Why are you creating brokers so frequently you need a friendly interface? And please confirm you're not allowing end users to create their own!!!
As to why the Java doesn't work, no clue. On this or any other Java issue.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
muthu_tek |
Posted: Wed Jul 21, 2010 4:25 am Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Thanks guys for valuable input.
Quote: |
As to why the Java doesn't work, no clue. On this or any other Java issue |
My program getting struck while call a mqsicreatebroker command in bat file.
But, If I terminate the program manually,broker is created successfully.I want to over come the java apps getting struck. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 21, 2010 5:16 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Does the batch file that "works" when you call mq commands attempt to read the output of a specific command?
Have you done anything to identify *where* in your program that it is "getting stuck"? |
|
Back to top |
|
 |
muthu_tek |
Posted: Wed Jul 21, 2010 5:41 am Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Quote: |
Does the batch file that "works" when you call mq commands attempt to read the output of a specific command? |
yes.it works fine.
Quote: |
*where* in your program that it is "getting stuck"? |
Application getting struck when it execute "mqsicreatebroker command" |
|
Back to top |
|
 |
mqmatt |
Posted: Wed Jul 21, 2010 6:44 am Post subject: |
|
|
 Grand Master
Joined: 04 Aug 2004 Posts: 1213 Location: Hursley, UK
|
Two other observations to throw into the mix:
1) I may be wrong, but I wasn't aware you could run batch files directly from java; I thought you had to exec "cmd /C start batfile.bat" instead.
2) Ensure that you're running in a valid environment before running any broker command; i.e. mqsiprofile has been sourced. |
|
Back to top |
|
 |
muthu_tek |
Posted: Wed Jul 21, 2010 7:08 am Post subject: |
|
|
Apprentice
Joined: 21 Jan 2010 Posts: 36 Location: Coimbatore,India
|
Quote: |
I wasn't aware you could run batch files directly from java |
We can run batch file from java
Quote: |
mqsiprofile has been sourced |
mqsiprofile path is exactly correct "C:\Program Files\IBM\MQSI\6.1\bin\mqsiprofile.cmd". |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jul 21, 2010 1:40 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
mqmatt wrote: |
mqsiprofile has been sourced |
mqsiprofile path is exactly correct "C:\Program Files\IBM\MQSI\6.1\bin\mqsiprofile.cmd". |
mqmatt did not ask you whether you had the right path to mqsiprofile...
What he was asking you is: Did you source the profile?
In other words, before executing the create broker command, did you check that the environment was prepared as needed?  _________________ MQ & Broker admin
Last edited by fjb_saper on Wed Jul 21, 2010 6:47 pm; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jul 21, 2010 3:44 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
In other words, before executing the create broker command, did you check that the environment was prepared as needed?  |
More specifically, did you source the mqsiprofile *before* running your Java program, *in* the same shell. |
|
Back to top |
|
 |
|