|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  trigger problem on AIX | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | gteddy | 
		  
		    
			  
				 Posted: Fri Sep 08, 2006 12:49 am    Post subject: trigger problem on AIX | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 14
  
  | 
		  
		    
			  
				I modifed a sample java program to backup the queue messages when they arrive on the source queue.
 
I configured everything that a trigger needs and it works well on Windows.
 
But when comes to AIX5.3, it fails to work.
 
One confuzed thing is : 
 
when i run 
 
   
	| Code: | 
   
  
	| javac -classpath /usr/mqm/java/lib/com.ibm.mq.jar TriggerBackup.java | 
   
 
 
it is fine, after that , i run:
 
   
	| Code: | 
   
  
	| java -cp /usr/mqm/java/lib/com.ibm.mq.jar TriggerBackup | 
   
 
 
it says
 
   
	| Code: | 
   
  
	
 
The java class is not found:  TriggerBackup
 
 | 
   
 
 
when run as a standalone program, the output should be "This must be a triggered application".
 
 
i don't know what's the problem with that, anybody helps me please!!
 
many thanks!
 
 
below is my code:
 
   
	| Code: | 
   
  
	
 
import java.io.*;
 
import java.lang.*;
 
import com.ibm.mq.*;
 
 
import java.util.*;
 
 
 
class MQTrigger
 
{
 
 
   private String structId;
 
   private String version;
 
   private String qName;
 
   private String processName;
 
   private String triggerData;
 
   private String applType;
 
   private String applId;
 
   private String envData;
 
   private String userData;
 
   private String qMgrName;
 
 
   
 
   public MQTrigger(String tmcStruct) throws StringIndexOutOfBoundsException
 
   {
 
 
      structId    = tmcStruct.substring(0,3).trim();
 
      version     = tmcStruct.substring(4,8).trim();
 
      qName       = tmcStruct.substring(8,55).trim();
 
      processName = tmcStruct.substring(56,103).trim();
 
      triggerData = tmcStruct.substring(104,167).trim();
 
      applType    = tmcStruct.substring(168,171).trim();
 
      applId      = tmcStruct.substring(172,427).trim();
 
      envData     = tmcStruct.substring(428,555).trim();
 
      userData    = tmcStruct.substring(556,683).trim();
 
      qMgrName    = tmcStruct.substring(684,730).trim();
 
 
   }
 
 
   public String getStructId()
 
   {
 
      return(structId);
 
   }
 
 
   public String getVersion()
 
   {
 
      return(version);
 
   }
 
 
   public String getQueueName()
 
   {
 
      return(qName);
 
   }
 
 
   public String getProcessName()
 
   {
 
      return(processName);
 
   }
 
 
   public String getTriggerData()
 
   {
 
      return(triggerData);
 
   }
 
 
   public String getApplicationType()
 
   {
 
      return(applType);
 
   }
 
 
   public String getApplicationId()
 
   {
 
      return(applId);
 
   }
 
 
   public String getEnvironmentData()
 
   {
 
      return(envData);
 
   }
 
 
   public String getUserData()
 
   {
 
      return(userData);
 
   }
 
 
   public String getQueueManagerName()
 
   {
 
      return(qMgrName);
 
   }
 
 
};
 
 
public class TriggerBackup 
 
{
 
 
 
   private MQQueueManager qMgr;
 
 
   public static void main (String args[]) throws IOException 
 
   {
 
      if (args.length < 1)
 
      {
 
         System.out.println("This must be a triggered application");
 
      }
 
      else
 
      {
 
         TriggerBackup tb = new TriggerBackup();
 
         tb.start(args);
 
      }
 
      System.exit(0);
 
   }
 
 
 
   public void start(String args[]) 
 
   {
 
      try
 
      {
 
         MQException.log = null;
 
         MQTrigger tmc = new MQTrigger(args[0]);
 
         //// Get QM name;
 
         qMgr = new MQQueueManager(tmc.getQueueManagerName());       
 
         /// Utilize distributionList
 
         String TQ=tmc.getUserData();
 
        // System.out.println(TQ);
 
         StringTokenizer st=new StringTokenizer(TQ);
 
         ArrayList targetQ=new ArrayList();
 
         while(st.hasMoreTokens())
 
         {
 
            targetQ.add(st.nextToken());
 
         }
 
         int number=targetQ.size();  
 
         //System.out.println(number);
 
         MQDistributionListItem [] items=new MQDistributionListItem[number];
 
         for(int i=0;i<number;i++)
 
         {
 
            MQDistributionListItem item=new  MQDistributionListItem();
 
            item.queueManagerName=tmc.getQueueManagerName();
 
            item.queueName=(String)targetQ.get(i);
 
            items[i]=item;
 
         }
 
         int options=MQC.MQOO_PASS_ALL_CONTEXT|MQC.MQOO_OUTPUT|MQC.MQOO_FAIL_IF_QUIESCING;
 
         MQDistributionList list=new MQDistributionList(qMgr,items,options,""); 
 
         //// open source queue and get message     
 
         int openOptions = MQC.MQOO_BROWSE|MQC.MQOO_INQUIRE;
 
         MQQueue triggerQueue = qMgr.accessQueue(tmc.getQueueName(), 
 
                                                 openOptions,
 
                                                 null, null, null);       
 
         MQGetMessageOptions gmo = new MQGetMessageOptions();
 
         gmo.options=MQC.MQGMO_BROWSE_FIRST | MQC.MQGMO_WAIT;
 
         gmo.waitInterval=MQC.MQWI_UNLIMITED;     
 
         MQPutMessageOptions pmo = new MQPutMessageOptions();
 
         long rc = 0;
 
         do
 
         {
 
            rc = 0;
 
            try
 
            {
 
               MQMessage triggerMessage = new MQMessage();
 
               triggerMessage.clearMessage();
 
               triggerMessage.correlationId = MQC.MQCI_NONE;
 
               triggerMessage.messageId = MQC.MQMI_NONE;
 
               triggerQueue.get(triggerMessage, gmo);
 
               System.out.println(triggerMessage.readLine());
 
               list.put(triggerMessage, pmo);
 
               System.out.println("Backup successful!");    
 
               gmo.options = MQC.MQGMO_BROWSE_NEXT | MQC.MQGMO_WAIT ;
 
            }
 
            catch (MQException mqEx)
 
            {
 
               rc = mqEx.reasonCode;
 
               if (rc != MQException.MQRC_NO_MSG_AVAILABLE)
 
               {
 
                  System.out.println(" PUT Message failed with rc = "  
 
                                     +  rc);
 
                  mqEx.printStackTrace();
 
               }
 
            }
 
            catch (Exception ex)
 
            {
 
               System.out.println("Generic exception: " + ex);
 
               rc = 1;
 
            }
 
 
       } while (rc == 0);
 
         list.close();
 
         triggerQueue.close();
 
         qMgr.disconnect();
 
      }
 
 
      catch (MQException mqEx)
 
      {
 
         System.out.println("MQ failed with completion code = " 
 
                            + mqEx.completionCode 
 
                            + " and reason code = " + mqEx.reasonCode);
 
      }
 
   }
 
 
}
 
 
 
 
 | 
   
 
 | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri Sep 08, 2006 2:22 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				Gosh, I guess that the local .class file that you produced with your javac is not actually on the CLASSPATH.
 
 
It's a shame you're not a Java programmer, because it's an easy thing to notice if you're a Java programmer. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Fri Sep 08, 2006 3:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				on www.nynjmq.org in one of the previous sessions (spring last year?) there is a ppt about how to use java triggering on unix (AIX....)
 
 
Enjoy    _________________ MQ & Broker admin | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | gteddy | 
		  
		    
			  
				 Posted: Fri Sep 08, 2006 4:03 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 14
  
  | 
		  
		    
			  
				
   
	| jefflowrey wrote: | 
   
  
	Gosh, I guess that the local .class file that you produced with your javac is not actually on the CLASSPATH.
 
 
It's a shame you're not a Java programmer, because it's an easy thing to notice if you're a Java programmer. | 
   
 
 
 
hi,jeff,thanks for help,, in fact i know something of Java programming,but i am really a newbie of UNIX. i don't know how things like Java work on AIX. would u please give more details ? many thanks. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri Sep 08, 2006 4:09 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				What does the "-cp" option do?
 
 
What did I say was the problem? _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | gteddy | 
		  
		    
			  
				 Posted: Sun Sep 10, 2006 10:46 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 14
  
  | 
		  
		    
			  
				i set all the enviroment vars right but my trigger programme still doesn't work. Below is what the exception like when a trigger message is coming.
 
   
	| Code: | 
   
  
	
 
$ runmqtrm -m QM_SITBRK2 -q java.init.queue          
 
5724-H72 (C) Copyright IBM Corp. 1994, 2005.  ALL RIGHTS RESERVED.
 
WebSphere MQ trigger monitor started.
 
 
__________________________________________________
 
Waiting for a trigger message
 
 
java TriggerBackup 'TMC    2java.trigger.queue                              java.process                                                                                                        java TriggerBackup                                                                                                                                                                                                                                                                                                                                                                              java.backup.queue                                                                                                               QM_SITBRK2                                      ' 
 
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't find library mqjbnd05  (libmqjbnd05.a or .so) in sun.boot.library.path or java.library.path
 
sun.boot.library.path=/usr/java14/jre/bin
 
java.library.path=/usr/java14/jre/bin:/usr/java14/jre/bin/classic:/usr/java14/jre/bin:/usr/lib
 
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2047)
 
        at java.lang.Runtime.loadLibrary0(Runtime.java:824)
 
        at java.lang.System.loadLibrary(System.java:910)
 
        at com.ibm.mq.MQSESSION.loadLib(MQSESSION.java:872)
 
        at com.ibm.mq.server.MQSESSION$1.run(MQSESSION.java:228)
 
        at java.security.AccessController.doPrivileged1(Native Method)
 
        at java.security.AccessController.doPrivileged(AccessController.java:287)
 
        at com.ibm.mq.server.MQSESSION.<clinit>(MQSESSION.java:222)
 
        at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:70)
 
        at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:492)
 
        at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:168)
 
        at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:179)
 
        at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:215)
 
        at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
 
        at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
 
        at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:772)
 
        at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:697)
 
        at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:657)
 
        at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
 
        at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:451)
 
        at TriggerBackup.start(TriggerBackup.java:121)
 
        at TriggerBackup.main(TriggerBackup.java:108)
 
End of application trigger.
 
 
__________________________________________________
 
 | 
   
 
 
 
i searched the forum and knew that some LIBPATH should be set.
 
and i set it.
 
   
	| Code: | 
   
  
	
 
export LIBPATH=/usr/mqm/java/lib
 
 | 
   
 
 
 
IBM developworks said its a defect of MQ5.3, however i'm using MQ6.0
 
   
	| Code: | 
   
  
	
 
$ dspmqver
 
Name:        WebSphere MQ
 
Version:     6.0.1.1
 
CMVC level:  p600-101-060504
 
BuildType:   IKAP - (Production)
 
 | 
   
 
 
 
How can I solve this problem, help me plz! | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Nigelg | 
		  
		    
			  
				 Posted: Mon Sep 11, 2006 12:40 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Grand Master
 
 Joined: 02 Aug 2004 Posts: 1046
  
  | 
		  
		    
			  
				The error says that it cannot find the WMQ java bindings library libmqjbnd05, and it even gives the path it searched on! Make sure the library is available in one of those directories.
 
Note that LIBPATH is cleared to standard dirs only when running a setuid program, like runmqtrm, so that setting it before starting runmqtrm has no effect. _________________ MQSeries.net helps those who help themselves.. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | gteddy | 
		  
		    
			  
				 Posted: Mon Sep 11, 2006 7:18 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 25 Aug 2006 Posts: 14
  
  | 
		  
		    
			  
				
   
	| Nigelg wrote: | 
   
  
	The error says that it cannot find the WMQ java bindings library libmqjbnd05, and it even gives the path it searched on! Make sure the library is available in one of those directories.
 
Note that LIBPATH is cleared to standard dirs only when running a setuid program, like runmqtrm, so that setting it before starting runmqtrm has no effect. | 
   
 
 
 
thanks Nigelg, i solved it    | 
			   
			 
		   | 
		 
		
		  | 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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |