javax.jms.Message.setIntProperty()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中javax.jms.Message.setIntProperty()方法的一些代码示例,展示了Message.setIntProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setIntProperty()方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:setIntProperty

Message.setIntProperty介绍

[英]Sets an int property value with the specified name into the message.
[中]在消息中设置具有指定名称的int属性值。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Test
public void userDefinedPropertyMappedToHeader() throws JMSException {
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setIntProperty("foo", 123);
  assertInboundHeader(jmsMessage, "foo", 123);
}

代码示例来源:origin: apache/nifi

message.setStringProperty(jmsPropName, value);
} else if (type.equalsIgnoreCase(PROP_TYPE_INTEGER)) {
  message.setIntProperty(jmsPropName, Integer.parseInt(value));
} else if (type.equalsIgnoreCase(PROP_TYPE_BOOLEAN)) {
  message.setBooleanProperty(jmsPropName, Boolean.parseBoolean(value));

代码示例来源:origin: spring-projects/spring-framework

@Test
public void userDefinedPropertyMappedToHeaderWithCustomPrefix() throws JMSException {
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setIntProperty("foo", 123);
  mapper.setInboundPrefix("custom_");
  assertInboundHeader(jmsMessage, "custom_foo", 123);
}

代码示例来源:origin: spring-projects/spring-integration

@Test
public void testUserDefinedPropertyMappedToHeader() throws JMSException {
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setIntProperty("foo", 123);
  DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
  Map<String, Object> headers = mapper.toHeaders(jmsMessage);
  Object attrib = headers.get("foo");
  assertNotNull(attrib);
  assertEquals(Integer.class, attrib.getClass());
  assertEquals(123, ((Integer) attrib).intValue());
}

代码示例来源:origin: spring-projects/spring-integration

@Test
public void testUserDefinedPropertyMappedToHeaderWithCustomPrefix() throws JMSException {
  javax.jms.Message jmsMessage = new StubTextMessage();
  jmsMessage.setIntProperty("foo", 123);
  DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
  mapper.setInboundPrefix("custom_");
  Map<String, Object> headers = mapper.toHeaders(jmsMessage);
  Object header = headers.get("custom_foo");
  assertNotNull(header);
  assertEquals(Integer.class, header.getClass());
  assertEquals(123, ((Integer) header).intValue());
}

代码示例来源:origin: org.apache.tomee/openejb-core

@Override
public void setIntProperty(final String name, final int value) throws JMSException {
  message.setIntProperty(name, value);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

public void setIntProperty(String name, int value) throws JMSException
{
 message.setIntProperty(name, value);
}

代码示例来源:origin: org.jboss.genericjms/generic-jms-ra-jar

public void setIntProperty(String name, int value) throws JMSException {
  message.setIntProperty(name, value);
}

代码示例来源:origin: org.apache.qpid/qpid-jca

/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
public void setIntProperty(final String name, final int value) throws JMSException
{
 if (_log.isTraceEnabled())
 {
   _log.trace("setIntProperty(" + name + ", " + value + ")");
 }
 _message.setIntProperty(name, value);
}

代码示例来源:origin: stackoverflow.com

public void ConvertSend() {
Map map = new HashMap();
map.put("Name", "Vimal");
map.put("Age", new Integer(45));
jmsTemplate.convertAndSend("jmsQueue", map, new MessagePostProcessor() {
  public Message postProcessMessage(Message message) throws JMSException {
    message.setIntProperty("ID", 9999);
    message.setJMSCorrelationID("123-99999");
    return message;
    }
  });
}

代码示例来源:origin: apache/activemq-artemis

/**
* Set property
*
* @param name  The name
* @param value The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setIntProperty(final String name, final int value) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setIntProperty(" + name + ", " + value + ")");
 }
 message.setIntProperty(name, value);
}

代码示例来源:origin: org.apache.activemq/artemis-ra

/**
* Set property
*
* @param name  The name
* @param value The value
* @throws JMSException Thrown if an error occurs
*/
@Override
public void setIntProperty(final String name, final int value) throws JMSException {
 if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
   ActiveMQRALogger.LOGGER.trace("setIntProperty(" + name + ", " + value + ")");
 }
 message.setIntProperty(name, value);
}

代码示例来源:origin: apache/activemq-artemis

public static Message sendMessageWithProperty(final Session session,
                       final Destination destination,
                       final String key,
                       final int value) throws JMSException {
 MessageProducer producer = session.createProducer(destination);
 Message message = session.createMessage();
 message.setIntProperty(key, value);
 producer.send(message);
 return message;
}

代码示例来源:origin: org.apache.activemq/activemq-optional

protected Message createMessage(LoggingEvent event) throws JMSException, NamingException {
  Message answer = null;
  Object value = event.getMessage();
  if (allowTextMessages && value instanceof String) {
    answer = getSession().createTextMessage((String)value);
  } else {
    answer = getSession().createObjectMessage((Serializable)value);
  }
  answer.setStringProperty("level", event.getLevel().toString());
  answer.setIntProperty("levelInt", event.getLevel().toInt());
  answer.setStringProperty("threadName", event.getThreadName());
  return answer;
}

代码示例来源:origin: apache/activemq-artemis

protected final void sendMessages(JMSContext context, JMSProducer producer, Queue queue, final int total) {
 try {
   for (int j = 0; j < total; j++) {
    StringBuilder sb = new StringBuilder();
    for (int m = 0; m < 200; m++) {
      sb.append(random.nextLong());
    }
    Message msg = context.createTextMessage(sb.toString());
    msg.setIntProperty("counter", j);
    producer.send(queue, msg);
   }
 } catch (JMSException cause) {
   throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause);
 }
}

代码示例来源:origin: apache/activemq-artemis

/**
* if a property is set as an <code>int</code>,
* it can also be read as an <code>int</code>.
*/
@Test
public void testInt2Int() {
 try {
   Message message = senderSession.createMessage();
   message.setIntProperty("prop", 127);
   Assert.assertEquals(127, message.getIntProperty("prop"));
 } catch (JMSException e) {
   fail(e);
 }
}

代码示例来源:origin: apache/activemq-artemis

/**
* if a property is set as an <code>int</code>,
* it can also be read as a <code>String</code>.
*/
@Test
public void testInt2String() {
 try {
   Message message = senderSession.createMessage();
   message.setIntProperty("prop", 127);
   Assert.assertEquals("127", message.getStringProperty("prop"));
 } catch (JMSException e) {
   fail(e);
 }
}

代码示例来源:origin: apache/activemq-artemis

private void sendMessageUsingOpenWire(String queueName) throws Exception {
 Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
 System.out.println("destination: " + destination);
 final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
 javax.jms.Message message = session.createMessage();
 message.setBooleanProperty("booleanProperty", false);
 message.setLongProperty("longProperty", 99999L);
 message.setByteProperty("byteProperty", (byte) 5);
 message.setIntProperty("intProperty", 979);
 message.setShortProperty("shortProperty", (short) 1099);
 message.setStringProperty("stringProperty", "HelloMessage");
 producer.send(message);
}

代码示例来源:origin: apache/activemq-artemis

/**
* if a property is set as an <code>int</code>,
* it can also be read as a <code>long</code>.
*/
@Test
public void testInt2Long() {
 try {
   Message message = senderSession.createMessage();
   message.setIntProperty("prop", 127);
   Assert.assertEquals(127L, message.getLongProperty("prop"));
 } catch (JMSException e) {
   fail(e);
 }
}

代码示例来源:origin: apache/activemq-artemis

protected void prepareMessage(final Message m) throws JMSException {
 m.setBooleanProperty("booleanProperty", true);
 m.setByteProperty("byteProperty", (byte) 3);
 m.setDoubleProperty("doubleProperty", 4.0);
 m.setFloatProperty("floatProperty", 5.0f);
 m.setIntProperty("intProperty", 6);
 m.setLongProperty("longProperty", 7);
 m.setShortProperty("shortProperty", (short) 8);
 m.setStringProperty("stringProperty", "this is a String property");
 m.setJMSCorrelationID("this is the correlation ID");
 m.setJMSReplyTo(ActiveMQServerTestCase.topic1);
 m.setJMSType("someArbitraryType");
}

相关文章