本文整理了Java中javax.jms.Message.getPropertyNames()
方法的一些代码示例,展示了Message.getPropertyNames()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getPropertyNames()
方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:getPropertyNames
[英]Returns an Enumeration of all the property names.
Note that JMS standard header fields are not considered properties and are not returned in this enumeration.
[中]返回所有属性名称的枚举。
请注意,JMS标准头字段不被视为属性,并且在此枚举中不会返回。
代码示例来源:origin: apache/nifi
@SuppressWarnings("unchecked")
private Map<String, String> extractMessageProperties(final Message message) {
final Map<String, String> properties = new HashMap<>();
try {
final Enumeration<String> propertyNames = message.getPropertyNames();
while (propertyNames.hasMoreElements()) {
String propertyName = propertyNames.nextElement();
properties.put(propertyName, String.valueOf(message.getObjectProperty(propertyName)));
}
} catch (JMSException e) {
this.processLog.warn("Failed to extract message properties", e);
}
return properties;
}
代码示例来源:origin: openzipkin/brave
static void doFilterProperties(
Message message, Set<String> namesToClear, ArrayList<Object> retainedProperties
) throws JMSException {
Enumeration<?> names = message.getPropertyNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object value = message.getObjectProperty(name);
if (!namesToClear.contains(name) && value != null) {
retainedProperties.add(name);
retainedProperties.add(value);
}
}
// redo the properties to keep
message.clearProperties();
for (int i = 0, length = retainedProperties.size(); i < length; i += 2) {
message.setObjectProperty(
retainedProperties.get(i).toString(),
retainedProperties.get(i + 1)
);
}
}
代码示例来源:origin: spring-projects/spring-framework
Enumeration<?> jmsPropertyNames = jmsMessage.getPropertyNames();
if (jmsPropertyNames != null) {
while (jmsPropertyNames.hasMoreElements()) {
代码示例来源:origin: spring-projects/spring-framework
@Test
public void headerConversionLazilyInvoked() throws JMSException {
javax.jms.Message jmsMessage = mock(javax.jms.Message.class);
when(jmsMessage.getPropertyNames()).thenThrow(new IllegalArgumentException("Header failure"));
MessagingMessageListenerAdapter listener = getSimpleInstance("simple", Message.class);
Message<?> message = listener.toMessagingMessage(jmsMessage);
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Header failure");
message.getHeaders(); // Triggers headers resolution
}
代码示例来源:origin: apache/nifi
public static Map<String, String> createAttributeMap(final Message message) throws JMSException {
final Map<String, String> attributes = new HashMap<>();
final Enumeration<?> enumeration = message.getPropertyNames();
while (enumeration.hasMoreElements()) {
final String propName = (String) enumeration.nextElement();
代码示例来源:origin: apache/flume
Map<String, String> headers = event.getHeaders();
@SuppressWarnings("rawtypes")
Enumeration propertyNames = message.getPropertyNames();
while (propertyNames.hasMoreElements()) {
String name = propertyNames.nextElement().toString();
代码示例来源:origin: wildfly/wildfly
for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) {
String name = props.nextElement();
代码示例来源:origin: apache/activemq
/**
* Copies the standard JMS and user defined properties from the givem
* message to the specified message
*
* @param fromMessage the message to take the properties from
* @param toMessage the message to add the properties to
* @throws JMSException
*/
public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID());
toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo()));
toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination()));
toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode());
toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered());
toMessage.setJMSType(fromMessage.getJMSType());
toMessage.setJMSExpiration(fromMessage.getJMSExpiration());
toMessage.setJMSPriority(fromMessage.getJMSPriority());
toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp());
Enumeration propertyNames = fromMessage.getPropertyNames();
while (propertyNames.hasMoreElements()) {
String name = propertyNames.nextElement().toString();
Object obj = fromMessage.getObjectProperty(name);
toMessage.setObjectProperty(name, obj);
}
}
}
代码示例来源:origin: spring-projects/spring-integration
Enumeration<?> jmsPropertyNames = jmsMessage.getPropertyNames();
if (jmsPropertyNames != null) {
while (jmsPropertyNames.hasMoreElements()) {
代码示例来源:origin: org.eclipse.ditto/ditto-services-amqpbridge-messaging
private Map<String, String> extractHeadersMapFromJmsMessage(final Message message) throws JMSException {
@SuppressWarnings("unchecked") final List<String> names = Collections.list(message.getPropertyNames());
return names.stream()
.map(key -> getPropertyAsEntry(message, key))
.filter(Objects::nonNull)
.collect(toMap(Entry::getKey, Entry::getValue));
}
代码示例来源:origin: org.fusesource.fabric.bridge/fabric-bridge
protected void getMessageProperties(Message message, Map<String, Object> map)
throws JMSException {
@SuppressWarnings("rawtypes")
Enumeration names;
names = message.getPropertyNames();
while (names.hasMoreElements()) {
String name = names.nextElement().toString();
Object value = message.getObjectProperty(name);
map.put(name, value);
}
}
代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging
@Override
public Map<String, Object> properties() {
Map<String, Object> headers = new HashMap<>();
try {
for(String name : (List<String>)Collections.list(this.baseMessage.getPropertyNames())) {
headers.put(name, this.baseMessage.getObjectProperty(name));
}
} catch (JMSException e) {
throw new IllegalStateException("Failed to read properties from message", e);
}
return headers;
}
代码示例来源:origin: com.github.fridujo/spring-automocker
public Map<String, Object> getHeaders() {
try {
return (Map<String, Object>) Collections.list(message.getPropertyNames())
.stream()
.collect(Collectors.toMap(Function.identity(), ThrowingFunction.silent(propertyName -> message.getObjectProperty((String) propertyName))));
} catch (JMSException e) {
throw new IllegalStateException("Unable to read JMS properties", e);
}
}
代码示例来源:origin: se.ugli.jocote/jocote
@SuppressWarnings("unchecked")
private static Map<String, Object> properties(final javax.jms.Message message) throws JMSException {
final HashMap<String, Object> result = new HashMap<>();
final Enumeration<String> propertyNames = message.getPropertyNames();
while (propertyNames.hasMoreElements()) {
final String propertyName = propertyNames.nextElement();
result.put(propertyName, message.getObjectProperty(propertyName));
}
result.put(JMS_MESSAGE_TYPE, getJmsMessageType(message));
return result;
}
代码示例来源:origin: org.ihtsdo.otf.common/otf-common
public void copyProperties(Message sourceMessage, Message targetMessage, String newPropertyNamePrefix) throws JMSException {
@SuppressWarnings("unchecked")
final Enumeration<String> propertyNames = sourceMessage.getPropertyNames();
while (propertyNames.hasMoreElements()) {
final String propertyName = propertyNames.nextElement();
targetMessage.setObjectProperty(newPropertyNamePrefix + propertyName, sourceMessage.getObjectProperty(propertyName));
}
}
代码示例来源:origin: rabbitmq/rabbitmq-jms-client
private static void copyProperties(RMQMessage rmqMsg, Message msg) throws JMSException {
@SuppressWarnings("unchecked")
Enumeration<String> propNames = msg.getPropertyNames();
while (propNames.hasMoreElements()) {
String name = propNames.nextElement();
rmqMsg.setObjectProperty(name, msg.getObjectProperty(name));
}
}
}
代码示例来源:origin: undera/jmeter-plugins
@Override
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
Enumeration<String> names = message.getPropertyNames();
messageProperties = new HashMap<String, String>();
while (names.hasMoreElements()) {
String name = names.nextElement();
messageProperties.put(name, message.getStringProperty(name));
}
BytesMessage bm = (BytesMessage) message;
byte[] transfer = new byte[(int) bm.getBodyLength()];
bm.readBytes(transfer);
return new String(transfer);
}
代码示例来源:origin: apache/cxf
private void readProperties(Message message) throws JMSException {
Enumeration<String> enm = CastUtils.cast(message.getPropertyNames());
while (enm.hasMoreElements()) {
String name = enm.nextElement();
String val = message.getStringProperty(name);
String unescapedName = name.replace("__", ".");
putProperty(unescapedName, val);
}
}
代码示例来源:origin: apache/activemq-artemis
/**
* Get property names
*
* @return The values
* @throws JMSException Thrown if an error occurs
*/
@Override
public Enumeration getPropertyNames() throws JMSException {
if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getPropertyNames()");
}
return message.getPropertyNames();
}
代码示例来源:origin: de.mhus.lib/mhu-lib-jms
public static IProperties getProperties(Message msg) throws JMSException {
MProperties out = new MProperties();
if (msg == null) return out;
@SuppressWarnings("unchecked")
Enumeration<String> enu = msg.getPropertyNames();
while (enu.hasMoreElements()) {
String name = enu.nextElement();
out.setProperty( name, msg.getObjectProperty(name) );
}
return out;
}
内容来源于网络,如有侵权,请联系作者删除!