Search This Blog

Monday, May 7, 2012

Start / Stop Tomcat app via wget command

In my previous post i explain how to Start / Stop Tomcat app via ant command.
Please follow the instruction in the beginning of the previous post , how to set to a tomcat user a permission to run such manager commands.

Wget is a great utility to  retrieve files from the WWW.

the urls below are fit to Tomcat 7.0.26.

to stop application under tomcat use:
wget http://username:pwd@my-server:8080/manager/text/stop?path=/MySite

to start application under tomcat use:
wget http://username:pwd@my-server:8080/manager/text/start?path=/MySite


very easily to add to any batch processing .
more options could be found here

Tomcat Server Control with Wget and the Tomcat Manager 

For a complete list of tomcat manager urls - visit the Manager App HOW-TO.

Yaniv Tzanany

Start / Stop Tomcat app via ant build

In this post i will try to explain how to start and stop Tomcat site from command line.
All my tests worked on Tomcat 7.0.26 , i am sure its will work on older version with minor changes.


You must set a permissions to the tomcat user you want to use, in my case i used the tomcat user.
i changed the tomcat-users.xml file as follow:
<user username="tomcat" password="xxx" roles="manager-gui,admin-gui,manager-script,manager-jmx,manager-status"/>

restart Tomcat

Option 1 - via ant build file

i used the next build.xml file:



<project name="My Application" default="compile" basedir=".">

  <!-- Configure properties to access the Manager application -->
  <property name="url"      value="http://il-yanivt:8080/manager/text"/>
  <property name="username" value="tomcat"/>
  <property name="password" value="tomcat"/>

  <path id="tomcat.classpath">
<fileset dir="C:/Program Files/Apache Software Foundation/apache-tomcat-7.0.26/lib" includes="*.jar" />
<fileset dir="C:/Program Files/Apache Software Foundation/apache-tomcat-7.0.26/bin" includes="*.jar" />
  </path>

<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="tomcat.classpath" />
</taskdef>

<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="tomcat.classpath" />
</taskdef>


<target name="stop" description="Stop web application">
<stop url="${url}" username="${username}" password="${password}" path="${site}"/>
</target>

<target name="start" description="Start web application">
<start url="${url}" username="${username}" password="${password}" path="${site}"/>
</target>

</project>


For a complete list of tomcat manager urls - visit the Manager App HOW-TO.

Open command windows  , change the directory where is your build.xml file is, and type the next command :
MySite mean your site name.

ant.bat start -Dsite=/MySite
ant.bat stop -Dsite=/MySite


enjoy 
Yaniv Tzanany

Tuesday, May 1, 2012

MQ CCDT files with C++


A client channel definition table (CCDT) file contains the details of all the client-connection channels defined at the WebSphere MQ Server. It is a binary file with the name amqclchl.tab and it is created automatically by the WebSphere MQ system when you create one or more client connection channels. You can find this file on the server at this location:

On Windows
\mqm\qmgrs\\@ipcc

On UNIX systems
/var/mqm/qmgrs//@ipcc

How to work with CCDT file in C++ MQ client ?
the easiest way to test your CCDT file is via the amqsputc program that shipped with MQ installation.
set the next env params ( the mqsslkeyr is for ssl key , i used in this sample , its optional, if no ssl required):
the paths is where to find your AMQCLCHL.TAB  files ...
more about Using WebSphere MQ environment variables

(make sure the MQSERVER env param is not set)


set mqchllib=C:\Program Files\IBM\WebSphere MQ\Qmgrs\MYQM\ssl\MQCLIENT
set mqchltab=AMQCLCHL.TAB
set mqsslkeyr=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT\key

run the next command
amqsputc   MY.Q


if all configured well you should connect to QM and put messages into yours 


How to use CCDT  with C++  ?
the idea is simple , make sure you set the env param before connecting to the QM.
avoid setting the queue name and the channel name , or any connection details.
only the Queue name is important.

putenv("mqchllib=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT");
putenv(" mqchltab=AMQCLCHL.TAB");
putenv("mqsslkeyr=C:\Program Files\IBM\WebSphere MQ\Qmgrs\ MYQM\ssl\MQCLIENT\key");

ImqQueueManager mgr;
mgr.connect();

ImqQueue q1;
q1.setName("MY.Q.NAME");

q1.setConnectionReference( m_QMgr );
q1.setOpenOptions(m_lOpenQueueInFlags);
q1.open();


Enjoy
Yaniv Tzanany