Refine search
DestinationStatistics stats = dest.getDestinationStatistics(); if (stats != null) { ActiveMQMapMessage statsMessage = new ActiveMQMapMessage(); statsMessage.setString("brokerName", regionBroker.getBrokerName()); statsMessage.setString("brokerId", regionBroker.getBrokerId().toString()); statsMessage.setString("destinationName", dest.getActiveMQDestination().toString()); statsMessage.setLong("size", stats.getMessages().getCount()); statsMessage.setLong("enqueueCount", stats.getEnqueues().getCount()); statsMessage.setLong("dequeueCount", stats.getDequeues().getCount()); statsMessage.setLong("dispatchCount", stats.getDispatched().getCount()); statsMessage.setLong("expiredCount", stats.getExpired().getCount()); statsMessage.setLong("inflightCount", stats.getInflight().getCount()); statsMessage.setLong("messagesCached", stats.getMessagesCached().getCount()); statsMessage.setLong("averageMessageSize", (long) stats.getMessageSize().getAverageSize()); statsMessage.setInt("memoryPercentUsage", dest.getMemoryUsage().getPercentUsage()); statsMessage.setLong("memoryUsage", dest.getMemoryUsage().getUsage()); statsMessage.setLong("memoryLimit", dest.getMemoryUsage().getLimit()); statsMessage.setDouble("averageEnqueueTime", stats.getProcessTime().getAverageTime()); statsMessage.setDouble("maxEnqueueTime", stats.getProcessTime().getMaxTime()); statsMessage.setDouble("minEnqueueTime", stats.getProcessTime().getMinTime()); statsMessage.setLong("consumerCount", stats.getConsumers().getCount()); statsMessage.setLong("producerCount", stats.getProducers().getCount()); statsMessage.setJMSCorrelationID(messageSend.getCorrelationId()); sendStats(producerExchange.getConnectionContext(), statsMessage, replyTo); ActiveMQMapMessage statsMessage = new ActiveMQMapMessage(); statsMessage.setJMSCorrelationID(messageSend.getCorrelationId()); sendStats(producerExchange.getConnectionContext(),statsMessage,replyTo);
@Override public Map<String, Object> getFields(Object o) throws OpenDataException { ActiveMQMapMessage m = (ActiveMQMapMessage)o; Map<String, Object> rc = super.getFields(o); try { rc.put(CompositeDataConstants.CONTENT_MAP, "" + m.getContentMap()); } catch (JMSException e) { rc.put(CompositeDataConstants.CONTENT_MAP, ""); } return rc; } }
private void initializeWriting() throws MessageNotWriteableException { checkReadOnlyBody(); setContent(null); }
@Override public Message copy() { ActiveMQMapMessage copy = new ActiveMQMapMessage(); copy(copy); return copy; }
/** * Sets an object value with the specified name into the Map. * <P> * This method works only for the objectified primitive object types (<code>Integer</code>,<code>Double</code>, * <code>Long</code> ...), <code>String</code> objects, and byte * arrays. * * @param name the name of the Java object * @param value the Java object value to set in the Map * @throws JMSException if the JMS provider fails to write the message due * to some internal error. * @throws IllegalArgumentException if the name is null or if the name is an * empty string. * @throws MessageFormatException if the object is invalid. * @throws MessageNotWriteableException if the message is in read-only mode. */ @Override public void setObject(String name, Object value) throws JMSException { initializeWriting(); if (value != null) { // byte[] not allowed on properties if (!(value instanceof byte[])) { checkValidObject(value); } put(name, value); } else { put(name, null); } }
if (message.propertyExists(QOS_PROPERTY_NAME)) { int ordinal = message.getIntProperty(QOS_PROPERTY_NAME); qoS = QoS.values()[ordinal]; qoS = message.isPersistent() ? QoS.AT_MOST_ONCE : QoS.AT_LEAST_ONCE; } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); msg.setReadOnlyBody(true); Map<String, Object> map = msg.getContentMap(); if (map != null) { result.payload(new Buffer(map.toString().getBytes("UTF-8")));
break; case org.apache.activemq.artemis.api.core.Message.MAP_TYPE: amqMsg = new ActiveMQMapMessage(); bytes = toAMQMessageMapType(buffer, isCompressed); break; break; case org.apache.activemq.artemis.api.core.Message.DEFAULT_TYPE: amqMsg = new ActiveMQMessage(); bytes = toAMQMessageDefaultType(buffer, isCompressed); break; amqMsg.setJMSType(type); amqMsg.setPersistent(coreMessage.isDurable()); amqMsg.setExpiration(coreMessage.getExpiration()); amqMsg.setPriority(coreMessage.getPriority());
if (message.getDataStructureType() == ActiveMQObjectMessage.DATA_STRUCTURE_TYPE) { ActiveMQObjectMessage msg = (ActiveMQObjectMessage) message.copy(); command.setContent(marshall(msg.getObject(), headers.get(Headers.TRANSFORMATION)).getBytes("UTF-8")); } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); command.setContent(marshall((Serializable) msg.getContentMap(), headers.get(Headers.TRANSFORMATION)).getBytes("UTF-8")); } else if (message.getDataStructureType() == ActiveMQMessage.DATA_STRUCTURE_TYPE && AdvisorySupport.ADIVSORY_MESSAGE_TYPE.equals(message.getType())) {
} else if (message instanceof MapMessage) { MapMessage mapMsg = (MapMessage)message; ActiveMQMapMessage msg = new ActiveMQMapMessage(); msg.setConnection(connection); Enumeration iter = mapMsg.getMapNames(); msg.setObject(name, mapMsg.getObject(name)); activeMessage = new ActiveMQMessage(); activeMessage.setConnection(connection);
/** * @return a new object instance */ public DataStructure createObject() { return new ActiveMQMapMessage(); }
@Override public <T> T getBody(final Class<T> c) throws JMSException { if (isBodyAssignableTo(c)) { return c.cast(ActiveMQMapMessage.class.isInstance(message) ? ActiveMQMapMessage.class.cast(message).getContentMap() : message /* unlikely */); } throw new MessageFormatException("Can't get the body with type " + c); }
protected ActiveMQMapMessage prepareSubscriptionMessage(SubscriptionViewMBean subscriber) throws JMSException { Broker regionBroker = getBrokerService().getRegionBroker(); ActiveMQMapMessage statsMessage = new ActiveMQMapMessage(); statsMessage.setString("brokerName", regionBroker.getBrokerName()); statsMessage.setString("brokerId", regionBroker.getBrokerId().toString()); statsMessage.setString("destinationName", subscriber.getDestinationName()); statsMessage.setString("clientId", subscriber.getClientId()); statsMessage.setString("connectionId", subscriber.getConnectionId()); statsMessage.setLong("sessionId", subscriber.getSessionId()); statsMessage.setString("selector", subscriber.getSelector()); statsMessage.setLong("enqueueCounter", subscriber.getEnqueueCounter()); statsMessage.setLong("dequeueCounter", subscriber.getDequeueCounter()); statsMessage.setLong("dispatchedCounter", subscriber.getDispatchedCounter()); statsMessage.setLong("dispatchedQueueSize", subscriber.getDispatchedQueueSize()); statsMessage.setInt("prefetchSize", subscriber.getPrefetchSize()); statsMessage.setInt("maximumPendingMessageLimit", subscriber.getMaximumPendingMessageLimit()); statsMessage.setBoolean("exclusive", subscriber.isExclusive()); statsMessage.setBoolean("retroactive", subscriber.isRetroactive()); statsMessage.setBoolean("slowConsumer", subscriber.isSlowConsumer()); return statsMessage; }
@SuppressWarnings("unchecked") protected ActiveMQMapMessage createMapMessage(HierarchicalStreamReader in) throws JMSException { ActiveMQMapMessage mapMsg = new ActiveMQMapMessage(); Map<String, Object> map = (Map<String, Object>) getXStream().unmarshal(in); for (String key : map.keySet()) { mapMsg.setObject(key, map.get(key)); } return mapMsg; }
@Override public String toString() { try { switch (message.getDataStructureType()) { case ActiveMQMessage.DATA_STRUCTURE_TYPE: return ""; case ActiveMQBlobMessage.DATA_STRUCTURE_TYPE: ActiveMQBlobMessage blob = (ActiveMQBlobMessage) message; return blob.getRemoteBlobUrl(); case ActiveMQMapMessage.DATA_STRUCTURE_TYPE: ActiveMQMapMessage map = (ActiveMQMapMessage)message; return map.getContentMap().toString(); case ActiveMQTextMessage.DATA_STRUCTURE_TYPE: ActiveMQTextMessage text = (ActiveMQTextMessage)message; return text.getText(); case ActiveMQBytesMessage.DATA_STRUCTURE_TYPE: case ActiveMQObjectMessage.DATA_STRUCTURE_TYPE: case ActiveMQStreamMessage.DATA_STRUCTURE_TYPE: ByteSequence data = message.getContent(); return "binary payload {length="+data.getLength()+", compressed="+message.isCompressed()+"}"; } } catch (JMSException e) { } return ""; } }
@Override public void storeContent() { try { if (getContent() == null && !map.isEmpty()) { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); MarshallingSupport.marshalPrimitiveMap(map, dataOut); dataOut.close(); setContent(bytesOut.toByteSequence()); } } catch (IOException e) { throw new RuntimeException(e); } }
MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setString("batch", "Hello World!"); producer.send(message);
if (message.propertyExists(QOS_PROPERTY_NAME)) { int ordinal = message.getIntProperty(QOS_PROPERTY_NAME); qoS = QoS.values()[ordinal]; qoS = message.isPersistent() ? QoS.AT_MOST_ONCE : QoS.AT_LEAST_ONCE; } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); msg.setReadOnlyBody(true); Map<String, Object> map = msg.getContentMap(); if (map != null) { result.payload(new Buffer(map.toString().getBytes("UTF-8")));
if (message.getDataStructureType() == ActiveMQObjectMessage.DATA_STRUCTURE_TYPE) { ActiveMQObjectMessage msg = (ActiveMQObjectMessage) message.copy(); command.setContent(marshall(msg.getObject(), headers.get(Headers.TRANSFORMATION)).getBytes("UTF-8")); } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); command.setContent(marshall((Serializable) msg.getContentMap(), headers.get(Headers.TRANSFORMATION)).getBytes("UTF-8")); } else if (message.getDataStructureType() == ActiveMQMessage.DATA_STRUCTURE_TYPE && AdvisorySupport.ADIVSORY_MESSAGE_TYPE.equals(message.getType())) {
} else if (message instanceof MapMessage) { MapMessage mapMsg = (MapMessage)message; ActiveMQMapMessage msg = new ActiveMQMapMessage(); msg.setConnection(connection); Enumeration iter = mapMsg.getMapNames(); msg.setObject(name, mapMsg.getObject(name)); activeMessage = new ActiveMQMessage(); activeMessage.setConnection(connection);
/** * @return a new object instance */ public DataStructure createObject() { return new ActiveMQMapMessage(); }