Package org.apache.qpid.qmf2.common

Examples of org.apache.qpid.qmf2.common.Handle


        try
        {
            System.out.println("** Starting BigPayloadAgentTest a test of basic Agent class functions **");
               
            Connection connection = ConnectionHelper.createConnection(url, "{reconnect: true}");
            _agent = new Agent(this);
            _agent.setVendor("test.com");
            _agent.setProduct("big-payload-agent");

            System.out.println("Agent name: " + _agent.getName());

View Full Code Here


        System.out.println("WorkItem type: " + wi.getType());

        if (wi.getType() == METHOD_CALL)
        {
            MethodCallWorkItem item = (MethodCallWorkItem)wi;
            MethodCallParams methodCallParams = item.getMethodCallParams();
            String methodName = methodCallParams.getName();
            ObjectId objectId = methodCallParams.getObjectId();

            QmfData inArgs = methodCallParams.getArgs();
            ObjectId controlAddress = _control.getObjectId();

            if (objectId.equals(controlAddress))
            {
                if (methodName.equals("processPayload"))
View Full Code Here

    {
        System.out.println("WorkItem type: " + wi.getType());

        if (wi.getType() == METHOD_CALL)
        {
            MethodCallWorkItem item = (MethodCallWorkItem)wi;
            MethodCallParams methodCallParams = item.getMethodCallParams();
            String methodName = methodCallParams.getName();
            ObjectId objectId = methodCallParams.getObjectId();

            QmfData inArgs = methodCallParams.getArgs();
            ObjectId controlAddress = _control.getObjectId();

            if (objectId.equals(controlAddress))
            {
                if (methodName.equals("processPayload"))
                {
                    System.out.println("Invoked processPayload method");

                    byte[] parameter = inArgs.getValue("parameter");
                    System.out.println("payload size = " + parameter.length);

                    QmfData outArgs = new QmfData();
                    outArgs.setValue("return", parameter);
                    _agent.methodResponse(methodName, item.getHandle(), outArgs, null);
                }
            }
        }
    }
View Full Code Here

    public void populateData() throws QmfException
    {
        System.out.println("*** BigPayloadAgentTest creating a control object ***");

        _control = new QmfAgentData(_controlSchema);
        _control.setValue("name", "controller");
        _agent.addObject(_control);
        System.out.println("BigPayloadAgentTest Schema control object added OK");
    }
View Full Code Here

            registerObjectClass(mammal);
            registerObjectClass(insect);
            registerObjectClass(reptile);
            registerObjectClass(bird);

            QmfAgentData cat = new QmfAgentData(mammal);
            cat.setValue("name", "cat");
            cat.setValue("legs", 4l);
            addObject(cat);

            QmfAgentData dog = new QmfAgentData(mammal);
            dog.setValue("name", "dog");
            dog.setValue("legs", 4l);
            addObject(dog);

            QmfAgentData rabbit = new QmfAgentData(mammal);
            rabbit.setValue("name", "rabbit");
            rabbit.setValue("legs", 4);
            addObject(rabbit);

            QmfAgentData horse = new QmfAgentData(mammal);
            horse.setValue("name", "horse");
            horse.setValue("legs", 4);
            addObject(horse);

            QmfAgentData human = new QmfAgentData(mammal);
            human.setValue("name", "human");
            human.setValue("legs", 2);
            addObject(human);


            QmfAgentData wasp = new QmfAgentData(insect);
            wasp.setValue("name", "wasp");
            wasp.setValue("legs", 6);
            addObject(wasp);

            QmfAgentData ant = new QmfAgentData(insect);
            ant.setValue("name", "ant");
            ant.setValue("legs", 6);
            addObject(ant);

            QmfAgentData crocodile = new QmfAgentData(reptile);
            crocodile.setValue("name", "crocodile");
            crocodile.setValue("legs", 4);
            addObject(crocodile);

            QmfAgentData gecko = new QmfAgentData(reptile);
            gecko.setValue("name", "gecko");
            gecko.setValue("legs", 4);
            addObject(gecko);

            QmfAgentData python = new QmfAgentData(reptile);
            python.setValue("name", "python");
            python.setValue("legs", 0);
            addObject(python);

            QmfAgentData hawk = new QmfAgentData(bird);
            hawk.setValue("name", "hawk");
            hawk.setValue("legs", 2);
            addObject(hawk);

            QmfAgentData ostrich = new QmfAgentData(bird);
            ostrich.setValue("name", "ostrich");
            ostrich.setValue("legs", 2);
            addObject(ostrich);


            System.out.println("total number of objects registered: " + _objectIndex.size());
View Full Code Here

    {
        try
        {
            System.out.println("*** Starting Test2 asynchronous Agent discovery using WorkQueue API ***");
               
            BlockingNotifier notifier = new BlockingNotifier();

            Connection connection = ConnectionHelper.createConnection(url, "{reconnect: true}");
            _console = new Console(notifier);
//console.disableAgentDiscovery(); // To miss all notifications this needs done before addConnection()
            _console.addConnection(connection);

            int count = 0;
            while (true)
            {
                notifier.waitForWorkItem();
                System.out.println("WorkItem available, WorkItem count = " + _console.getWorkitemCount());

                WorkItem wi;
                while ((wi = _console.getNextWorkitem(0)) != null)
                {
View Full Code Here

//System.out.println("content = " + content);
//System.out.println("opcode = " + opcode);
//System.out.println("routingKey = " + routingKey);
//System.out.println("contentType = " + contentType);

            Handle handle = new Handle(message.getJMSCorrelationID(), message.getJMSReplyTo());

            if (opcode.equals("_agent_locate_request"))
            {
                handleLocateRequest(handle);
            }
View Full Code Here

        if (wi.getType() == SUBSCRIBE_REQUEST)
        {
            SubscribeRequestWorkItem item = (SubscribeRequestWorkItem)wi;
            SubscriptionParams params = item.getSubscriptionParams();
            Handle handle = item.getHandle();

            System.out.println("Subscribe Request User ID = " + params.getUserId());

            try
            {
                Subscription subscription = new Subscription(this, params);
                _subscriptions.put(subscription.getSubscriptionId(), subscription);
                _timer.schedule(subscription, 0, params.getPublishInterval());

                if (subscription == null)
                {
System.out.println("Requested Subscription has already expired or been cancelled");
                    QmfData error = new QmfData();
                    error.setValue("error_text", "Requested Subscription has already expired or been cancelled");
                    _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), null, 0, 0, error);
                }
                else
                {
                    _agent.subscriptionResponse(handle, subscription.getConsoleHandle(), subscription.getSubscriptionId(),
                                               subscription.getDuration(), subscription.getInterval(), null);
                }
            }
            catch (QmfException qmfe)
            {
                _agent.raiseException(handle, "Subscribe Request failed, invalid Query: " + qmfe.getMessage());
            }
        }

        if (wi.getType() == RESUBSCRIBE_REQUEST)
        {
            ResubscribeRequestWorkItem item = (ResubscribeRequestWorkItem)wi;
            ResubscribeParams params = item.getResubscribeParams();
            Handle handle = item.getHandle();

            System.out.println("Resubscribe Request User ID = " + params.getUserId());

            String subscriptionId = params.getSubscriptionId();
            Subscription subscription = _subscriptions.get(subscriptionId);
View Full Code Here

            }

            // If we get to here the Agent from whence the Event came should be registered and should
            // have Event reception enabled, so we should be able to send events to the EventListener

            Handle handle = new Handle(message.getJMSCorrelationID());
            if (opcode.equals("_method_response") || opcode.equals("_exception"))
            {
                if (AMQPMessage.isAMQPMap(message))
                {
                    _eventListener.onEvent(
                        new MethodResponseWorkItem(handle, new MethodResult(AMQPMessage.getMap(message)))
                    );
                }
                else
                {
                    _log.info("onMessage() Received Method Response message in incorrect format");
                }
            }
            // Query Response. The only asynchronous query response we expect to see is the result of an async
            // refresh() call on QmfConsoleData so the number of results in the returned list *should* be one.
            if (opcode.equals("_query_response") && content.equals("_data"))
            {
                if (AMQPMessage.isAMQPList(message))
                {
                    List<Map> list = AMQPMessage.getList(message);
                    for (Map m : list)
                    {
                        _eventListener.onEvent(new ObjectUpdateWorkItem(handle, new QmfConsoleData(m, agent)));
                    }
                }
                else
                {
                    _log.info("onMessage() Received Query Response message in incorrect format");
                }
            }

            // This block handles responses to createSubscription and refreshSubscription
            if (opcode.equals("_subscribe_response"))
            {
                if (AMQPMessage.isAMQPMap(message))
                {
                    String correlationId = message.getJMSCorrelationID();
                    SubscribeParams params = new SubscribeParams(correlationId, AMQPMessage.getMap(message));
                    String subscriptionId = params.getSubscriptionId();

                    if (subscriptionId != null && correlationId != null)
                    {
                        SubscriptionManager subscription = _subscriptionById.get(subscriptionId);
                        if (subscription == null)
                        { // This is a createSubscription response so the correlationId should be the consoleHandle
                            subscription = _subscriptionByHandle.get(correlationId);
                            if (subscription != null)
                            {
                                _subscriptionById.put(subscriptionId, subscription);
                                subscription.setSubscriptionId(subscriptionId);
                                subscription.setDuration(params.getLifetime());
                                String replyHandle = subscription.getReplyHandle();
                                if (replyHandle == null)
                                {
                                    subscription.signal();
                                }
                                else
                                {
                                    _eventListener.onEvent(new SubscribeResponseWorkItem(new Handle(replyHandle), params));
                                }
                            }
                        }
                        else
                        { // This is a refreshSubscription response
                            params.setConsoleHandle(subscription.getConsoleHandle());
                            subscription.setDuration(params.getLifetime());
                            subscription.refresh();
                            _eventListener.onEvent(new SubscribeResponseWorkItem(handle, params));
                        }
                    }
                }
                else
                {
                    _log.info("onMessage() Received Subscribe Response message in incorrect format");
                }
            }

            // Subscription Indication - in other words the asynchronous results of a Subscription
            if (opcode.equals("_data_indication") && content.equals("_data"))
            {
                if (AMQPMessage.isAMQPList(message))
                {
                    String consoleHandle = handle.getCorrelationId();
                    if (consoleHandle != null && _subscriptionByHandle.containsKey(consoleHandle))
                    { // If we have a valid consoleHandle the data has come from a "real" Subscription.
                        List<Map> list = AMQPMessage.getList(message);
                        List<QmfConsoleData> resultList = new ArrayList<QmfConsoleData>(list.size());
                        for (Map m : list)
View Full Code Here

                    final String handle = replyHandle;
                    Thread thread = new Thread()
                    {
                        public void run()
                        {
                            _eventListener.onEvent(new SubscribeResponseWorkItem(new Handle(handle), params));
                        }
                    };
                    thread.start();
                }
                return null;
View Full Code Here

TOP

Related Classes of org.apache.qpid.qmf2.common.Handle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.