예제 #1
0
void Listener::browse() 
{ 
  subscriptions.subscribe(*this, "condor_queue", SubscriptionSettings(FlowControl::unlimited(), ACCEPT_MODE_NONE, ACQUIRE_MODE_NOT_ACQUIRED));     
  subscriptions.run(); 
}
예제 #2
0
/*
 *  argv[1] host
 *  argv[2] port
 *  argv[3] server name
 *  argv[4] command name
 *  argv[5..N] args to the command
 */
int
main ( int argc, char ** argv )
{
    const char* host = argv[1];
    int port = atoi(argv[2]);


    Connection connection;

    try
    {
        connection.open ( host, port );
        Session session = connection.newSession ( );

        // Make a queue and bind it to fanout.
        string myQueue = session.getId().getName();

        session.queueDeclare ( arg::queue=myQueue,
                               arg::exclusive=true,
                               arg::autoDelete=true
                             );

        session.exchangeBind ( arg::exchange="amq.fanout",
                               arg::queue=myQueue,
                               arg::bindingKey="my-key"
                             );

        // Get ready to listen for the wait-response.
        // or maybe a get-response.
        // ( Although this may not be one of those types
        // of command, get ready anyway.
        SubscriptionManager subscriptions ( session );
        ResponseListener responseListener ( subscriptions );
        subscriptions.subscribe ( responseListener, myQueue );

        bool response_command = false;
        if(! strcmp("exec_wait", argv[4] ))
            response_command = true;
        else
        if(! strcmp("exited", argv[4] ))
            response_command = true;
        else
        if(! strcmp("get", argv[4] ))
            response_command = true;

        // Send the payload message.
        // Skip "qrsh host_name port"
        Message message;
        stringstream ss;
        for ( int i = 3; i < argc; ++ i )
            ss << argv[i] << ' ';

        message.setData ( ss.str() );

        session.messageTransfer(arg::content=message,
                                arg::destination="amq.fanout");

        if ( response_command )
            subscriptions.run();

        session.close();
        connection.close();
        return responseListener.exitCode;
    }
    catch ( exception const & e)
    {
        cerr << e.what() << endl;
    }

    return 1;
}
예제 #3
0
/*
FUNCTION:listen()
DESC: function to acquire/dequeue messages from the qpid borker queue by giving control over to run -not used!
*/
void Listener::listen() {
  subscriptions.run();
}