ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » mqsicreatebroker command calling from java

Post new topic  Reply to topic Goto page 1, 2  Next
 mqsicreatebroker command calling from java « View previous topic :: View next topic » 
Author Message
muthu_tek
PostPosted: Tue Jul 20, 2010 9:10 pm    Post subject: mqsicreatebroker command calling from java Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
muthu_tek
PostPosted: Tue Jul 20, 2010 9:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
smdavies99
PostPosted: Tue Jul 20, 2010 11:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
muthu_tek
PostPosted: Tue Jul 20, 2010 11:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
mqjeff
PostPosted: Wed Jul 21, 2010 2:55 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The solution is immediately obvious from the errors you have posted.
Back to top
View user's profile Send private message
muthu_tek
PostPosted: Wed Jul 21, 2010 3:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
muthu_tek
PostPosted: Wed Jul 21, 2010 4:04 am    Post subject: Reply with quote

Apprentice

Joined: 21 Jan 2010
Posts: 36
Location: Coimbatore,India

Any Help ?
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Vitor
PostPosted: Wed Jul 21, 2010 4:16 am    Post subject: Reply with quote

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
View user's profile Send private message
muthu_tek
PostPosted: Wed Jul 21, 2010 4:25 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
mqjeff
PostPosted: Wed Jul 21, 2010 5:16 am    Post subject: Reply with quote

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
View user's profile Send private message
muthu_tek
PostPosted: Wed Jul 21, 2010 5:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
mqmatt
PostPosted: Wed Jul 21, 2010 6:44 am    Post subject: Reply with quote

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
View user's profile Send private message
muthu_tek
PostPosted: Wed Jul 21, 2010 7:08 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
fjb_saper
PostPosted: Wed Jul 21, 2010 1:40 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20703
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
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Jul 21, 2010 3:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » mqsicreatebroker command calling from java
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.