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

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

本文整理了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

  1. /**
  2. * Returns how many times the message has been delivered
  3. *
  4. * @param message
  5. * @return
  6. * @throws JMSException
  7. */
  8. private int getDeliveryNumber(Message message) throws JMSException {
  9. return message.getIntProperty("JMSXDeliveryCount");
  10. }

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

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

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

  1. public int getIntProperty(String name) throws JMSException
  2. {
  3. return message.getIntProperty(name);
  4. }

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

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

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

  1. /**
  2. * Get property
  3. * @param name The name
  4. * @return The value
  5. * @exception JMSException Thrown if an error occurs
  6. */
  7. public int getIntProperty(final String name) throws JMSException
  8. {
  9. if (_log.isTraceEnabled())
  10. {
  11. _log.trace("getIntProperty(" + name + ")");
  12. }
  13. return _message.getIntProperty(name);
  14. }

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

  1. public int getMessageIntProperty(String aMessagePropertyName) throws AsynchAEException {
  2. try {
  3. return message.getIntProperty(aMessagePropertyName);
  4. } catch (Exception e) {
  5. throw new AsynchAEException(e);
  6. }
  7. }

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

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

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

  1. /**
  2. * Get property
  3. *
  4. * @param name The name
  5. * @return The value
  6. * @throws JMSException Thrown if an error occurs
  7. */
  8. @Override
  9. public int getIntProperty(final String name) throws JMSException {
  10. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  11. ActiveMQRALogger.LOGGER.trace("getIntProperty(" + name + ")");
  12. }
  13. return message.getIntProperty(name);
  14. }

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

  1. /**
  2. * Get property
  3. *
  4. * @param name The name
  5. * @return The value
  6. * @throws JMSException Thrown if an error occurs
  7. */
  8. @Override
  9. public int getIntProperty(final String name) throws JMSException {
  10. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  11. ActiveMQRALogger.LOGGER.trace("getIntProperty(" + name + ")");
  12. }
  13. return message.getIntProperty(name);
  14. }

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

  1. @Override
  2. public void onMessage(final Message msg) {
  3. count++;
  4. try {
  5. msg.getIntProperty("counter");
  6. } catch (JMSException e) {
  7. e.printStackTrace();
  8. }
  9. if (count == NUM) {
  10. allMessagesReceived.countDown();
  11. }
  12. }
  13. }

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

  1. private void receiveJMS(int nMsgs, ConnectionFactory factory) throws JMSException {
  2. Connection connection2 = factory.createConnection();
  3. Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
  4. connection2.start();
  5. MessageConsumer consumer = session2.createConsumer(session2.createQueue(testQueueName));
  6. for (int i = 0; i < nMsgs; i++) {
  7. Message message = consumer.receive(5000);
  8. Assert.assertNotNull(message);
  9. Assert.assertEquals(i, message.getIntProperty("i"));
  10. }
  11. connection2.close();
  12. }

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

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

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

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

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

  1. @Test
  2. public void testJMSXDeliveryCountConversion() throws Exception {
  3. Message m1 = queueProducerSession.createMessage();
  4. queueProducer.send(m1);
  5. Message m2 = queueConsumer.receive(2000);
  6. int count = m2.getIntProperty("JMSXDeliveryCount");
  7. ProxyAssertSupport.assertEquals(String.valueOf(count), m2.getStringProperty("JMSXDeliveryCount"));
  8. ProxyAssertSupport.assertEquals(count, m2.getLongProperty("JMSXDeliveryCount"));
  9. }
  10. }

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

  1. /**
  2. * if a property is set as a <code>byte</code>,
  3. * it can also be read as an <code>int</code>.
  4. */
  5. @Test
  6. public void testByte2Int() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setByteProperty("prop", (byte) 127);
  10. Assert.assertEquals(127, message.getIntProperty("prop"));
  11. } catch (JMSException e) {
  12. fail(e);
  13. }
  14. }

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

  1. /**
  2. * if a property is set as a <code>short</code>,
  3. * it can also be read as an <code>int</code>.
  4. */
  5. @Test
  6. public void testShort2Int() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setShortProperty("prop", (short) 127);
  10. Assert.assertEquals(127, message.getIntProperty("prop"));
  11. } catch (JMSException e) {
  12. fail(e);
  13. }
  14. }

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

  1. /**
  2. * if a property is set as an <code>int</code>,
  3. * it can also be read as an <code>int</code>.
  4. */
  5. @Test
  6. public void testInt2Int() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setIntProperty("prop", 127);
  10. Assert.assertEquals(127, message.getIntProperty("prop"));
  11. } catch (JMSException e) {
  12. fail(e);
  13. }
  14. }

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

  1. /**
  2. * if a property is set as a <code>java.lang.String</code>,
  3. * it can also be read as a <code>int</code> as long as the <code>String</code>
  4. * is a correct representation of a <code>int</code> (e.g. <code>"0"</code>).
  5. */
  6. @Test
  7. public void testString2Int_1() {
  8. try {
  9. Message message = senderSession.createMessage();
  10. message.setStringProperty("prop", "0");
  11. Assert.assertEquals(0, message.getIntProperty("prop"));
  12. } catch (JMSException e) {
  13. fail(e);
  14. }
  15. }

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

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

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

  1. protected final void receiveMessages(JMSConsumer consumer, final int start, final int msgCount, final boolean ack) {
  2. try {
  3. for (int i = start; i < msgCount; i++) {
  4. Message message = consumer.receive(100);
  5. Assert.assertNotNull("Expecting a message " + i, message);
  6. final int actual = message.getIntProperty("counter");
  7. Assert.assertEquals("expected=" + i + ". Got: property['counter']=" + actual, i, actual);
  8. if (ack)
  9. message.acknowledge();
  10. }
  11. } catch (JMSException cause) {
  12. throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause);
  13. }
  14. }

相关文章