Package org.apache.qpid.qmf2.common

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


                        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


            }

            // 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

                        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

//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

    {
        // TODO There are a couple of WorkItem types that won't serialise correctly - SubscriptionIndicationWorkItem
        // and MethodCallWorkItem. Their params require a custom serialiser - though they probably won't be used
        // from a REST API so they've been parked for now.
        String type = "\"_type\":\"" + data.getType() + "\",";
        Handle handle = data.getHandle();
        String handleString = handle == null ? "" : "\"_handle\":\"" + handle.getCorrelationId() + "\",";
        String params = "\"_params\":" + fromObject(data.getParams());

        return "{" + type + handleString + params + "}";
    }
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

//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() == 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

            if (correlationId.equals("queueStatsHandle"))
            { // If it is (and it should be!!) then it's our queue object Subscription
                List<QmfConsoleData> data = indication.getData();
                for (QmfConsoleData record : data)
                {
                    ObjectId id = record.getObjectId();
                    if (record.isDeleted())
                    { // If the object was deleted by the Agent we remove it from out Map
                        _objects.remove(id);
                    }
                    else
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.