Examples of MapMessage


Examples of javax.jms.MapMessage

        }

        try
        {
            Destination destination = (replyHandle == null) ? _replyAddress : _asyncReplyAddress;
            MapMessage request = _syncSession.createMapMessage();
            request.setJMSReplyTo(destination);
            request.setJMSCorrelationID(replyHandle);
            request.setStringProperty("x-amqp-0-10.app-id", "qmf2");
            request.setStringProperty("method", "request");
            request.setStringProperty("qmf.opcode", "_subscribe_refresh_indication");
            request.setStringProperty("qpid.subject", agentName);

            request.setObject("_subscription_id", subscriptionId);
            if (lifetime > 0)
            {
                request.setObject("_duration", lifetime);
            }

            // Wrap request & response in synchronized block in case any other threads invoke a request
            // it would be somewhat unfortunate if their response got interleaved with ours!!
            synchronized(this)
View Full Code Here

Examples of javax.jms.MapMessage

    public final void subscriptionResponse(final Handle handle, final Handle consoleHandle, final String subscriptionId,
                                           final long lifetime, final long publishInterval, final QmfData error)
    {
        try
        {
            MapMessage response = _syncSession.createMapMessage();
            response.setJMSCorrelationID(handle.getCorrelationId());
            response.setStringProperty("x-amqp-0-10.app-id", "qmf2");
            response.setStringProperty("method", "response");
            response.setStringProperty("qmf.opcode", "_subscribe_response");
            response.setStringProperty("qmf.agent", _name);
            response.setStringProperty("qpid.subject", handle.getRoutingKey());
   
            if (error == null)
            {
                response.setObject("_subscription_id", subscriptionId);
                response.setObject("_duration", lifetime);
                response.setObject("_interval", publishInterval);
            }
            else
            {
                Map<String, Object> errorMap = error.mapEncode();
                for (Map.Entry<String, Object> entry : errorMap.entrySet())
                {
                    response.setObject(entry.getKey(), entry.getValue());
                }
            }
            sendResponse(handle, response);
        }
        catch (JMSException jmse)
View Full Code Here

Examples of javax.jms.MapMessage

        }
        String agentName = agent.getName();

        try
        {
            MapMessage request = _syncSession.createMapMessage();
            request.setStringProperty("x-amqp-0-10.app-id", "qmf2");
            request.setStringProperty("method", "request");
            request.setStringProperty("qmf.opcode", "_subscribe_cancel_indication");
            request.setStringProperty("qpid.subject", agentName);
            request.setObject("_subscription_id", subscriptionId);

            synchronized(this)
            {
                if (!_subscriptionEmulationEnabled || !agentName.equals(_brokerAgentName))
                {
View Full Code Here

Examples of javax.jms.MapMessage

                String vendorKey = _vendor.replace(".", "_");
                String productKey = _product.replace(".", "_");
                String instanceKey = _instance.replace(".", "_");
                String subject = "agent.ind.heartbeat." + vendorKey + "." + productKey + "." + instanceKey;

                MapMessage response = _syncSession.createMapMessage();
                response.setStringProperty("x-amqp-0-10.app-id", "qmf2");
                response.setStringProperty("method", "indication");
                response.setStringProperty("qmf.opcode", "_agent_heartbeat_indication");
                response.setStringProperty("qmf.agent", _name);
                response.setStringProperty("qpid.subject", subject);
                setValue("_timestamp", System.currentTimeMillis()*1000000l);
                response.setObject("_values", mapEncode());
           
                // Send heartbeat messages with a Time To Live (in msecs) set to two times the _heartbeatInterval
                // to prevent stale heartbeats from getting to the consoles.
                _broadcaster.send(response, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY,
                                  _heartbeatInterval*2000);
 
View Full Code Here

Examples of javax.jms.MapMessage

            throw new MessageFormatException("Attempting to do AMQPMessage.getMap() on null Message");
        }
        else if (message instanceof MapMessage)
        {
            Map<String, Object> object = new HashMap<String, Object>();
            MapMessage msg = (MapMessage)message;
            for (Enumeration e = msg.getMapNames(); e.hasMoreElements();)
            {
                String key = (String)e.nextElement();
                object.put(key, msg.getObject(key));
            }
           
            if (object.size() == 0)
            { // If there is no MapMessage content return an empty Map.
                return object;
            }

            // If there is MapMessage content include the Message properties in the returned Map.
            for (Enumeration e = msg.getPropertyNames(); e.hasMoreElements();)
            {
                String prop = (String)e.nextElement();
                object.put(prop, QmfData.getString(msg.getObjectProperty(prop)));
            }

            // Should be msg.getStringProperty("JMSXUserID"). See comments above for the reason behind this evil hack.
            org.apache.qpid.client.message.AMQMessageDelegate_0_10 delegate = (org.apache.qpid.client.message.AMQMessageDelegate_0_10)(((org.apache.qpid.client.message.AbstractJMSMessage)msg).getDelegate());
            byte[] rawUserId = delegate.getMessageProperties().getUserId();
View Full Code Here

Examples of javax.jms.MapMessage

             * out of this by iterating through the getMapNames() Enumeration and copying the Objects into the List.
             * This amount of copying doesn't feel healthy and we can't even work out the capacity for the List
             * a priori, but I'm not sure of a better way at present. I can't say I much like how amqp/list or indeed
             * amqp/map are currently encoded. I'd *much* prefer to see them exposed as JMS ObjectMessage.
             */
            MapMessage msg = (MapMessage)message;
            List resultList = new ArrayList(50); // Initial capacity of 50, can we better estimate this?

            for (Enumeration e = msg.getMapNames(); e.hasMoreElements();)
            {
                String key = (String)e.nextElement();
                resultList.add(msg.getObject(key));
            }
            return resultList;
        }
        else
        {
View Full Code Here

Examples of javax.jms.MapMessage

            }
            dataOut.close();
            return NIOConverter.toByteBuffer(bytesOut.toByteArray());
        }
        if (message instanceof MapMessage) {
            final MapMessage msg = (MapMessage)message;
            final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            final DataOutputStream dataOut = new DataOutputStream(bytesOut);
            for (final Enumeration en = msg.getMapNames(); en.hasMoreElements();) {
                final Object obj = msg.getObject(en.nextElement().toString());
                writeData(dataOut, obj);
            }
            dataOut.close();
            return NIOConverter.toByteBuffer(bytesOut.toByteArray());
        }
View Full Code Here

Examples of javax.jms.MapMessage

                    bodyMessage.setHeader(JMS_MESSAGE_TYPE, JmsMessageType.Bytes);
                    bodyMessage.setBody(result);
                    break;
                case Map:
                    Map<String, Object> body = new HashMap<String, Object>();
                    MapMessage mapMessage = (MapMessage)message;
                    Enumeration<String> names = mapMessage.getMapNames();
                    while (names.hasMoreElements()) {
                        String key = names.nextElement();
                        Object value = mapMessage.getObject(key);
                        body.put(key, value);
                    }
                    bodyMessage.setHeader(JMS_MESSAGE_TYPE, JmsMessageType.Map);
                    bodyMessage.setBody(body);
                    break;
View Full Code Here

Examples of javax.jms.MapMessage

                BytesMessage bytesMessage = session.createBytesMessage();
                bytesMessage.writeBytes((byte[])payload);
                answer = bytesMessage;
                break;
            case Map:
                MapMessage mapMessage = session.createMapMessage();
                Map<String, Object> objMap = (Map<String, Object>)payload;
                Set<String> keys = objMap.keySet();
                for (String key : keys) {
                    Object value = objMap.get(key);
                    mapMessage.setObject(key, value);
                }
                answer = mapMessage;
                break;
            case Object:
                ObjectMessage objectMessage = session.createObjectMessage();
View Full Code Here

Examples of javax.jms.MapMessage

            BytesMessage result = session.createBytesMessage();
            result.writeBytes((byte[])body);
            return result;
        }
        if (body instanceof Map) {
            MapMessage result = session.createMapMessage();
            Map<?, ?> map = (Map<?, ?>)body;
            try {
                populateMapMessage(result, map, context);
                return result;
            } catch (JMSException e) {
                // if MapMessage creation failed then fall back to Object Message
                LOG.warn("Can not populate MapMessage will fall back to ObjectMessage, cause by: " + e.getMessage());
            }
        }
        if (body instanceof String) {
            return session.createTextMessage((String)body);
        }
        if (body instanceof File || body instanceof Reader || body instanceof InputStream || body instanceof ByteBuffer) {
            BytesMessage result = session.createBytesMessage();
            byte[] bytes = context.getTypeConverter().convertTo(byte[].class, body);
            result.writeBytes(bytes);
            return result;
        }
        if (body instanceof Serializable) {
            return session.createObjectMessage((Serializable)body);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.