Search This Blog

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

Wednesday, April 18, 2012

How To MQ SSL

You Must READ this : WebSphere MQ SSL channels on Windows

MQ SSL

SSL configuration of the Websphere MQ Java/JMS client

How to Set MQ ssl details programmatically (c++)?
My C++ code looks like this ( the MQ header from v7/6 version):

ImqChannel * pchannel = new ImqChannel;
pchannel->setChannelName("SSL_CHANNEL");
pchannel->setTransportType(MQXPT_TCP);
pchannel->setConnectionName ("myhostname(1414)");
pchannel->setSslCipherSpecification("TRIPLE_DES_SHA_US"); // its must be the same as the channel 

ImqQueueManager mgr;
mgr.setName("myQMgr");
mgr.setChannelReference(pchannel);
mgr.setKeyRepository("c:\\keys\\key");

To complete this post , and if you interesting with How to MQ SSL with CCDT files follow this post.

Yaniv Tzanany

Tuesday, April 10, 2012

Android App Development – Linear and Relative Layouts

the next article made my day, very good explanation with samples regards Android layout ... and all the headache about this subject.
Android App Development – Layouts Part One: Linear and Relative Layouts | Mobile Orchard:

enjoy
Yaniv T

ASP.NET ListView with DetailsView - get the new item selected

i have a listview with datapager attach to it , and when you clikc on an item you can edit/insert/delete this item in the details view control.

my problem was , when i add new item , so its added to the end of my list , mean to the last page, so if i wanted to continue edit it or chnage it , i needed to goto last page select it and edit it... bad idea...

so here is my solution on this


        protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
        {
// get the total items
            int total = DataPager1.TotalRowCount;
// calc the last page
            int pages = total / DataPager1.PageSize;
// set the pager to the last page
            DataPager1.SetPageProperties(pages * DataPager1.PageSize, DataPager1.PageSize, true);
// bind again my listview
            ListView1.DataBind();
// select the last one
            ListView1.SelectedIndex = ListView1.Items.Count - 1;
/// boooom your new item show again in your detals view

        }

enjoy
Yaniv Tzanany

Wednesday, March 14, 2012

android - DefaultHttpClient to AndroidHttpClient - Stack Overflow

while accessing the WEB on the main thread i get the next exception
AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)

"StrictMode.ThreadPolicy was introduced since API Level 9 and the default thread policy had been changed since API Level 11, which in short, does not allow network operation (include HttpClient and HttpUrlConnection) get executed on UI thread. if you do this, you get NetworkOnMainThreadException.

This restriction can be changed, using:

    if (android.os.Build.VERSION.SDK_INT > 9) {
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
    }"

more android - DefaultHttpClient to AndroidHttpClient - Stack Overflow:

Yaniv Tzanany

Thursday, March 8, 2012

Tomcat 7 - Failed to start component - with DB2 jars

When i deployed my old app on Tomcat 7.0.26 , i get the next error while start up my site.


EVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/YANIV_DEV]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file
at org.apache.tomcat.util.bcel.classfile.ClassParser.readID(ClassParser.java:238)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:114)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2032)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1923)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1891)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1877)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Mar 8, 2012 3:26:36 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\YANIV_DEV
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/YANIV_DEV]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:898)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)



The solution for such error was:

I changed the  $TOMCAT_HOME/conf/catalina.properties and i add db2jcc4.jar to tomcat.util.scan.DefaultJarScanner.jarsToSkip property value.
It is used to turn off classpath scanning (which is used across JavaEE 6 specs implementations).


i found the solution here
db2 - Including DB2JCC4 in Tomcat 7:

enjoy
Yaniv Tzanany