本文整理了Java中javax.jms.Message.setObjectProperty()
方法的一些代码示例,展示了Message.setObjectProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setObjectProperty()
方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:setObjectProperty
[英]Sets a Java object property value with the specified name into the message.
Note that this method works only for the objectified primitive object types ( Integer, Double, Long ...) and String objects.
[中]在消息中设置具有指定名称的Java对象属性值。
请注意,此方法仅适用于对象化的基本对象类型(整数、双精度、长…)和字符串对象。
代码示例来源:origin: spring-projects/spring-framework
try {
String propertyName = this.fromHeaderName(headerName);
jmsMessage.setObjectProperty(propertyName, value);
代码示例来源: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: wildfly/wildfly
/**
* Sets all properties we carry onto the message.
*
* @param message
* @throws JMSException
*/
private void setProperties(Message message) throws JMSException {
for (SimpleString name : properties.getPropertyNames()) {
message.setObjectProperty(name.toString(), properties.getProperty(name));
}
}
代码示例来源:origin: apache/nifi
message.setFloatProperty(jmsPropName, Float.parseFloat(value));
} else if (type.equalsIgnoreCase(PROP_TYPE_OBJECT)) {
message.setObjectProperty(jmsPropName, value);
} else {
logger.warn("Attribute key '{}' for {} has value '{}', but expected one of: integer, string, object, byte, double, float, long, short, boolean; not adding this property",
代码示例来源:origin: stackoverflow.com
Message message = session.createMessage();
message.setObjectProperty("OS", "LINUX");
producer.send(message);
代码示例来源: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
try {
String propertyName = this.fromHeaderName(headerName);
jmsMessage.setObjectProperty(propertyName, value);
jmsMessage.setObjectProperty(propertyName, value.toString());
代码示例来源:origin: org.jboss.genericjms/generic-jms-ra-jar
public void setObjectProperty(String name, Object value) throws JMSException {
message.setObjectProperty(name, value);
}
代码示例来源:origin: org.apache.tomee/openejb-core
private void setProperties(final Message message) throws JMSException {
for (final Map.Entry<String, Object> entry : properties.entrySet()) {
message.setObjectProperty(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: org.ihtsdo.otf.common/otf-common
private void setProperties(Message message, Map<String, ? extends Object> messageProperties) throws JMSException {
if (messageProperties != null) {
for (Map.Entry<String, ? extends Object> stringObjectEntry : messageProperties.entrySet()) {
message.setObjectProperty(stringObjectEntry.getKey(), stringObjectEntry.getValue());
}
}
}
代码示例来源:origin: org.fusesource.fabric.bridge/fabric-bridge
protected void setMessageProperties(Message message,
Map<String, Object> properties) throws JMSException {
for (Entry<String, Object> entry : properties.entrySet()) {
message.setObjectProperty(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: com.github.hqstevenson.junit/activemq-junit
public static void setMessageProperties(Message message, Map<String, Object> properties) throws JMSException {
if (properties != null) {
for (Map.Entry<String, Object> property : properties.entrySet()) {
message.setObjectProperty(property.getKey(), property.getValue());
}
}
}
代码示例来源:origin: org.projectodd.wunderboss/wunderboss-messaging
protected static void fillInProperties(javax.jms.Message message, Map<String, Object> properties) throws JMSException {
for(Map.Entry<String, Object> each : properties.entrySet()) {
message.setObjectProperty(each.getKey(), each.getValue());
}
}
代码示例来源:origin: org.geoserver.community/gs-jms-commons
protected void updateProperties(Message message) throws JMSException {
// append the name of the server
message.setObjectProperty(
JMSConfiguration.INSTANCE_NAME_KEY,
properties.get(JMSConfiguration.INSTANCE_NAME_KEY));
// set other properties
final Set<Entry<Object, Object>> set = properties.entrySet();
final Iterator<Entry<Object, Object>> it = set.iterator();
while (it.hasNext()) {
final Entry<Object, Object> entry = it.next();
message.setObjectProperty(entry.getKey().toString(), entry.getValue());
}
}
代码示例来源:origin: apache/activemq-artemis
public static void setMessageProperties(Message message, Map<String, Object> properties) {
if (properties != null && properties.size() > 0) {
for (Map.Entry<String, Object> property : properties.entrySet()) {
try {
message.setObjectProperty(property.getKey(), property.getValue());
} catch (JMSException jmsEx) {
throw new EmbeddedJMSResourceException(String.format("Failed to set property {%s = %s}", property.getKey(), property.getValue().toString()), jmsEx);
}
}
}
}
代码示例来源:origin: org.apache.activemq/artemis-junit
public static void setMessageProperties(Message message, Map<String, Object> properties) {
if (properties != null && properties.size() > 0) {
for (Map.Entry<String, Object> property : properties.entrySet()) {
try {
message.setObjectProperty(property.getKey(), property.getValue());
} catch (JMSException jmsEx) {
throw new EmbeddedJMSResourceException(String.format("Failed to set property {%s = %s}", property.getKey(), property.getValue().toString()), jmsEx);
}
}
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-platform-connector
private void addProperties(final Event event, final Message message) throws JMSException {
Map<String, Object> filterableValues = event.getFilterableValues();
if (filterableValues == null) {
addDefaultProperties(event, message);
} else {
Set<Entry<String, Object>> entrySet = filterableValues.entrySet();
for (Entry<String, Object> entry : entrySet) {
message.setObjectProperty(entry.getKey(), entry.getValue());
}
}
}
代码示例来源: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: org.jboss.eap/wildfly-client-all
/**
* Sets all properties we carry onto the message.
*
* @param message
* @throws JMSException
*/
private void setProperties(Message message) throws JMSException {
for (SimpleString name : properties.getPropertyNames()) {
message.setObjectProperty(name.toString(), properties.getProperty(name));
}
}
代码示例来源:origin: io.tracee/tracee-jms
/**
* Writes the current TraceeContext to the given javaee message.
* This method is idempotent.
*/
protected void writeTraceeContextToMessage(Message message) throws JMSException {
if (!backend.isEmpty() && backend.getConfiguration().shouldProcessContext(AsyncDispatch)) {
final Map<String, String> filteredContext = backend.getConfiguration().filterDeniedParams(backend, AsyncDispatch);
message.setObjectProperty(TraceeConstants.JMS_HEADER_NAME, filteredContext);
}
}
内容来源于网络,如有侵权,请联系作者删除!