/** * 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"); }
@Override public int getIntProperty(final String name) throws JMSException { return message.getIntProperty(name); }
public int getIntProperty(String name) throws JMSException { return message.getIntProperty(name); }
public int getIntProperty(String name) throws JMSException { return message.getIntProperty(name); }
/** * 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); }
public int getMessageIntProperty(String aMessagePropertyName) throws AsynchAEException { try { return message.getIntProperty(aMessagePropertyName); } catch (Exception e) { throw new AsynchAEException(e); } }
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); }
/** * 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); }
/** * 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); }
@Override public void onMessage(final Message msg) { count++; try { msg.getIntProperty("counter"); } catch (JMSException e) { e.printStackTrace(); } if (count == NUM) { allMessagesReceived.countDown(); } } }
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(); }
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(); }
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; }
@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")); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
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); } }