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

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

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

Message.getIntProperty介绍

[英]Returns the value of the int property with the specified name.
[中]返回具有指定名称的int属性的值。

代码示例

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

/**
 * Returns how many times the message has been delivered
 * 
 * @param message
 * @return
 * @throws JMSException
 */
private int getDeliveryNumber(Message message) throws JMSException {
  return message.getIntProperty("JMSXDeliveryCount");
}

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

@Override
public int getIntProperty(final String name) throws JMSException {
  return message.getIntProperty(name);
}

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

public int getIntProperty(String name) throws JMSException
{
 return message.getIntProperty(name);
}

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

public int getIntProperty(String name) throws JMSException {
  return message.getIntProperty(name);
}

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

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

代码示例来源:origin: org.apache.uima/uimaj-as-jms

public int getMessageIntProperty(String aMessagePropertyName) throws AsynchAEException {
 try {
  return message.getIntProperty(aMessagePropertyName);
 } catch (Exception e) {
  throw new AsynchAEException(e);
 }
}

代码示例来源:origin: org.apache.uima/uimaj-as-jms

private boolean isException(Message message) throws Exception {
 int payload;
 if (message.propertyExists(AsynchAEMessage.Payload)) {
  payload = ((Integer) message.getIntProperty(AsynchAEMessage.Payload)).intValue();
 } else {
  throw new InvalidMessageException("Message Does not Contain Payload property");
 }
 return (AsynchAEMessage.Exception == payload ? true : false);
}

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

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

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

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

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

@Override
 public void onMessage(final Message msg) {
   count++;
   try {
    msg.getIntProperty("counter");
   } catch (JMSException e) {
    e.printStackTrace();
   }
   if (count == NUM) {
    allMessagesReceived.countDown();
   }
 }
}

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

private void receiveJMS(int nMsgs, ConnectionFactory factory) throws JMSException {
 Connection connection2 = factory.createConnection();
 Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
 connection2.start();
 MessageConsumer consumer = session2.createConsumer(session2.createQueue(testQueueName));
 for (int i = 0; i < nMsgs; i++) {
   Message message = consumer.receive(5000);
   Assert.assertNotNull(message);
   Assert.assertEquals(i, message.getIntProperty("i"));
 }
 connection2.close();
}

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

protected void readMessagesOnBroker(Connection connection, int count, AtomicInteger sequence) throws Exception {
 Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 Queue queue = session.createQueue(getQueueName());
 MessageConsumer consumer = session.createConsumer(queue);
 for (int i = 0; i < MESSAGE_COUNT; ++i) {
   Message message = consumer.receive(RECEIVE_TIMEOUT);
   assertNotNull(message);
   LOG.debug("Read message #{}: type = {}", i, message.getClass().getSimpleName());
   String gid = message.getStringProperty("JMSXGroupID");
   int seq = message.getIntProperty("JMSXGroupSeq");
   LOG.debug("Message assigned JMSXGroupID := {}", gid);
   LOG.debug("Message assigned JMSXGroupSeq := {}", seq);
   assertEquals("Sequence order should match", sequence.incrementAndGet(), seq);
 }
 session.close();
}

代码示例来源:origin: com.github.mrharibo.micronet/mn-network

protected Response parseResponseMessage(Message message) throws JMSException {
  StatusCode status = StatusCode.fromInt(message.getIntProperty(NetworkConstants.STATUS_CODE_PROPERTY));
  Response response = new Response(status, readTextMessage(message));
  response.getParameters().deserialize(message.getStringProperty(NetworkConstants.PARAMETER_PROPERTY));
  return response;
}

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

@Test
  public void testJMSXDeliveryCountConversion() throws Exception {
   Message m1 = queueProducerSession.createMessage();
   queueProducer.send(m1);

   Message m2 = queueConsumer.receive(2000);

   int count = m2.getIntProperty("JMSXDeliveryCount");
   ProxyAssertSupport.assertEquals(String.valueOf(count), m2.getStringProperty("JMSXDeliveryCount"));
   ProxyAssertSupport.assertEquals(count, m2.getLongProperty("JMSXDeliveryCount"));
  }
}

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

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

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

/**
* if a property is set as a <code>short</code>,
* it can also be read as an <code>int</code>.
*/
@Test
public void testShort2Int() {
 try {
   Message message = senderSession.createMessage();
   message.setShortProperty("prop", (short) 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 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 a <code>java.lang.String</code>,
* it can also be read as a <code>int</code> as long as the <code>String</code>
* is a correct representation of a <code>int</code> (e.g. <code>"0"</code>).
*/
@Test
public void testString2Int_1() {
 try {
   Message message = senderSession.createMessage();
   message.setStringProperty("prop", "0");
   Assert.assertEquals(0, message.getIntProperty("prop"));
 } catch (JMSException e) {
   fail(e);
 }
}

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

/**
* if a property is set as a <code>double</code>,
* to get is as an <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
@Test
public void testDouble2Int() {
 try {
   Message message = senderSession.createMessage();
   message.setDoubleProperty("prop", 127.0);
   message.getIntProperty("prop");
   Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
 } catch (MessageFormatException e) {
 } catch (JMSException e) {
   fail(e);
 }
}

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

protected final void receiveMessages(JMSConsumer consumer, final int start, final int msgCount, final boolean ack) {
 try {
   for (int i = start; i < msgCount; i++) {
    Message message = consumer.receive(100);
    Assert.assertNotNull("Expecting a message " + i, message);
    final int actual = message.getIntProperty("counter");
    Assert.assertEquals("expected=" + i + ". Got: property['counter']=" + actual, i, actual);
    if (ack)
      message.acknowledge();
   }
 } catch (JMSException cause) {
   throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause);
 }
}

相关文章

微信公众号

最新文章

更多