|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
I have developed a java 1.6 program to delete MQs using WAS |
« View previous topic :: View next topic » |
Author |
Message
|
lakshminarayana |
Posted: Thu Jul 05, 2012 11:35 pm Post subject: I have developed a java 1.6 program to delete MQs using WAS |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 1
|
I am running this code using cron ,I have all the permissions under WSADMIN ,but i am getting MQEXCEPTION for reasoncode 2035 ,I know this is UnAuthorised Queue manger connection,
When i was tested this code ,the same exception was returned so i used this command to run the code ie sudo su - wsadmin,then it works fine
Note : I want to run this on root ,when i run this using cron script on root ,i am getting MQ Exception 2035,do we need to provide the permission to root also or is there any other simpler way to accomlish this,please see this code BOLD is where the program controll is terminating about the permissions
public int browseDeleteQueue( String queueManager,String queueName,String jobInterval,
long currentTime ) throws SystemException
{
int status =0;
int count=0;
MQQueue queue =null;
MQQueueManager qMgr=null;
try {
LogManager.logInfo("Method entry -MessageUtil::browseDeleteQueue("+queueManager+" , "+queueName+" , "+jobInterval+" , "+currentTime);
LogManager.logInfo( "MQMessage: browseQueue. Queue Name: "
+ queueName );
int openOptions = MQC.MQOO_INPUT_EXCLUSIVE | MQC.MQOO_BROWSE; // String queueManager=PropertiesReader.getEntitlementReader().getValue(BEEConstants.QUEUEMANAGER );
qMgr = new MQQueueManager(queueManager);
queue = qMgr.accessQueue(queueName, openOptions,
null, null, null);
//int depth = queue.getCurrentDepth();
//System.out.println("depth of Queue ="+depth);
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
MQMessage queueMessage = new MQMessage();
/***************************/
/* Set up a loop exit flag */
/***************************/
boolean done = false;
do {
try {
/*****************************************/
/* Reset the message and IDs to be empty */
/*****************************************/
queueMessage.clearMessage();
queueMessage.correlationId = MQC.MQCI_NONE;
queueMessage.messageId = MQC.MQMI_NONE;
LogManager.logInfo("correlationId"+queueMessage.correlationId);
/**************************************************/
/* Browse the message, display it, and ask if the */ |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 06, 2012 5:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
in the cron for root you can use su - wsadmin
Why do you need exclusive access in input mode? You realize that you are not very likely to get it if anything else has the queue attached?
And why oh why are you using java base inside of a J2EE app server and not JMS???
I don't think from the code you posted that the message gets effectively deleted from the queue. Furthermore you cannot rely on the qdepth attribute as uncommitted messages contribute to the qdepth but cannot be accessed...
You need to consume the messages until no message is accessible...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 06, 2012 5:13 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
I don't think from the code you posted that the message gets effectively deleted from the queue. |
Going by the last line of the segment posted, I assumed there was more to it.
I don't see any reason to run any program that talks to MQ as the root user. It's a terribly idea in general to run any application that doesn't have to be root as root. And no MQ application has to be root.
And it's also a terrible idea to run any MQ application as either the MQM user or the root user.
So please don't do this! |
|
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
|
|
|
|