/* \n Copyright 1999-2011 (c) My-Channels \n Copyright (c) 2012-2014 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. \n\n Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.\n */\n #include "nSampleApp.h" #include "nChannel.h" #include "nSession.h" #include "nChannelAttributes.h" #include "nSessionFactory.h" #include "nSessionPausedException.h" #include "nSecurityException.h" #include "nSessionNotConnectedException.h" #include "nUnexpectedResponseException.h" #include "nRequestTimedOutException.h" #include "nChannelNotFoundException.h" #include "nUnknownRemoteRealmException.h" using namespace com::pcbsys::nirvana::client; using namespace com::pcbsys::nirvana::apps; /** * Deletes a join between a nirvana channel and a nirvana queue */ class deletequeuejoin : public nSampleApp { private: static std::string RNAME; std::string chanName; std::string queueName; static deletequeuejoin* mySelf; /** * This method demonstrates the Nirvana API calls necessary to delete * a queue join. * It is called after all command line arguments have been received and * validated * * @param realmDetails a string* containing the possible RNAME values * @param nRproperty the length of the realmDetails array */ void doit(std::string* realmDetails, int nRproperty){ mySelf->constructSession(realmDetails, nRproperty); //Deletes the specified queue join try{ //Create the channel attributes object to locate the source channel first nChannelAttributes* nca = new nChannelAttributes(); nca->setName( chanName ); //Create the channel attributes for the destination queue nChannelAttributes* dest = new nChannelAttributes(); dest->setName( queueName ); //Obtain a reference to the source channel nChannel* mySrcChannel = m_pSession->findChannel( nca ); //Obtain a reference to the destination queue nQueue* myDstQueue = m_pSession->findQueue( dest ); mySrcChannel->deleteJoin( myDstQueue ); } //Handle errors catch(nChannelNotFoundException cnfe){ printf("The channel specified could not be found."); printf("Please ensure that the channel exists in the REALM you connect to."); exit(1); } catch (nSecurityException se) { printf("Unsufficient permissions for the requested operation."); printf("Please check the ACL settings on the server."); exit(1); } catch (nSessionNotConnectedException snce) { printf("The session object used is not physically connected to the Nirvana realm."); printf("Please ensure the realm is up and check your RNAME value."); exit(1); } catch (nUnexpectedResponseException ure) { printf("The Nirvana REALM has returned an unexpected response."); printf("Please ensure the Nirvana REALM and client API used are compatible."); exit(1); } catch (nUnknownRemoteRealmException urre) { printf("The channel specified resided in a remote realm which could not be found."); printf("Please ensure the channel name specified is correct."); exit(1); } catch (nRequestTimedOutException rtoe) { printf("The requested operation has timed out waiting for a response from the REALM."); printf("If this is a very busy REALM ask your administrator to increase the client timeout values."); exit(1); } catch (nBaseClientException nbce) { printf("An error occured while creating the Channel Attributes object."); exit(1); } //Close the session we opened try{ nSessionFactory::close ( m_pSession ); } catch(Exception){} //Close any other sessions so that we can exit nSessionFactory::shutdown ( ); } void processArgs(int argc, char** argv) { if(argc < 4) { Usage(); exit(1); } if(argc > 3){ RNAME = argv[1]; chanName = argv[2]; queueName = argv[3]; } } /** * Prints the usage message for this class */ static void Usage() { printf( "Usage ...\n\n" ); printf("deletequeuejoin \n\n"); printf( " \n\n"); printf( " - the rname of the server to connect to\n"); printf( " - Channel name parameter of the local channel name to join\n" ); printf( " - Queue name parameter of the remote queue name to join\n" ); } public: static int Main(int argc, char** argv) { //Create an instance for this class mySelf = new deletequeuejoin(); //Process command line arguments mySelf->processArgs(argc,argv); //Process the local REALM RNAME details int nRproperty; std::string* rproperties = parseRealmProperties(RNAME,nRproperty); //sets nRproperty to the number of realms in RNAME //delete the queue join specified mySelf->doit(rproperties,nRproperty); return 0; } }; // End of deletequeuejoin Class deletequeuejoin* deletequeuejoin::mySelf = NULL; std::string deletequeuejoin::RNAME = ""; int main (int argc, char** argv) { return deletequeuejoin::Main (argc, argv); }