@Override public int getInt(final String name) throws JMSException { return message.getInt(name); }
private void testMapMessageSendReceive(Connection producerConnection, Connection consumerConnection) throws Throwable { long time = System.currentTimeMillis(); Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(getQueueName()); MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { System.out.println("Sending " + i); MapMessage message = session.createMapMessage(); message.setInt("i", i); message.setIntProperty("count", i); producer.send(message); } Session sessionConsumer = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue consumerQueue = sessionConsumer.createQueue(getQueueName()); final MessageConsumer consumer = sessionConsumer.createConsumer(consumerQueue); for (int i = 0; i < NUM_MESSAGES; i++) { MapMessage m = (MapMessage) consumer.receive(5000); Assert.assertNotNull("Could not receive message count=" + i + " on consumer", m); Assert.assertEquals(i, m.getInt("i")); Assert.assertEquals(i, m.getIntProperty("count")); } long taken = (System.currentTimeMillis() - time) / 1000; System.out.println("taken = " + taken); }
public int getInt(String name) throws JMSException { return ((MapMessage) message).getInt(name); }
public int getInt(String name) throws JMSException { return ((MapMessage) message).getInt(name); }
/** * Get * @param name The name * @return The value * @exception JMSException Thrown if an error occurs */ public int getInt(final String name) throws JMSException { if (_log.isTraceEnabled()) { _log.trace("getInt(" + name + ")"); } return ((MapMessage)_message).getInt(name); }
/** * Get * * @param name The name * @return The value * @throws JMSException Thrown if an error occurs */ @Override public int getInt(final String name) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getInt(" + name + ")"); } return ((MapMessage) message).getInt(name); }
/** * Get * * @param name The name * @return The value * @throws JMSException Thrown if an error occurs */ @Override public int getInt(final String name) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getInt(" + name + ")"); } return ((MapMessage) message).getInt(name); }
protected Event demapEvent(MapMessage mapMessage, String moduleName, String componentName, List<Payload> payloads, List<String> eventFieldNames) throws JMSException, EventDeserialisationException { String eventId = null; int priority = -1; Date timestamp = null; for(String fieldName : eventFieldNames){ if (fieldName.equals(EVENT_FIELD_ID)){ eventId=mapMessage.getString(EVENT_FIELD_ID); } else if (fieldName.equals(EVENT_FIELD_PRIORITY)){ priority=mapMessage.getInt(EVENT_FIELD_PRIORITY); } else if (fieldName.equals(EVENT_FIELD_TIMESTAMP)){ timestamp=new Date(mapMessage.getLong(EVENT_FIELD_TIMESTAMP)); } else{ throw new EventDeserialisationException("Unknown map entry ["+fieldName+"]"); } } return new Event(eventId, priority, timestamp, payloads); }
int stageId = map.getInt("stageId"); if (this.stageId != stageId) { throw new IllegalStateException(String.format("Received stage id %s expected %s ",
Assert.assertEquals(i, mapMessage.getInt("intOne")); Assert.assertEquals(Integer.toString(i), mapMessage.getString("stringOne"));
@Override protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException { super.assertEquivalent(m, mode, redelivery); MapMessage mm = (MapMessage) m; ProxyAssertSupport.assertEquals(true, mm.getBoolean("boolean")); ProxyAssertSupport.assertEquals((byte) 3, mm.getByte("byte")); byte[] bytes = mm.getBytes("bytes"); ProxyAssertSupport.assertEquals((byte) 3, bytes[0]); ProxyAssertSupport.assertEquals((byte) 4, bytes[1]); ProxyAssertSupport.assertEquals((byte) 5, bytes[2]); ProxyAssertSupport.assertEquals((char) 6, mm.getChar("char")); ProxyAssertSupport.assertEquals(new Double(7.0), new Double(mm.getDouble("double"))); ProxyAssertSupport.assertEquals(new Float(8.0f), new Float(mm.getFloat("float"))); ProxyAssertSupport.assertEquals(9, mm.getInt("int")); ProxyAssertSupport.assertEquals(10L, mm.getLong("long")); ProxyAssertSupport.assertEquals("this is an object", mm.getObject("object")); ProxyAssertSupport.assertEquals((short) 11, mm.getShort("short")); ProxyAssertSupport.assertEquals("this is a string", mm.getString("string")); } }
private void receiveMapMessage(boolean useCore) throws Exception { MapMessage mapMessage = (MapMessage) receiveMessage(useCore); boolean booleanVal = mapMessage.getBoolean("boolean-type"); assertTrue(booleanVal); byte byteVal = mapMessage.getByte("byte-type"); assertEquals((byte) 10, byteVal); byte[] bytesVal = mapMessage.getBytes("bytes-type"); byte[] originVal = TEXT.getBytes(); assertEquals(originVal.length, bytesVal.length); for (int i = 0; i < bytesVal.length; i++) { assertTrue(bytesVal[i] == originVal[i]); } char charVal = mapMessage.getChar("char-type"); assertEquals('A', charVal); double doubleVal = mapMessage.getDouble("double-type"); assertEquals(55.3D, doubleVal, 0.1D); float floatVal = mapMessage.getFloat("float-type"); assertEquals(79.1F, floatVal, 0.1F); int intVal = mapMessage.getInt("int-type"); assertEquals(37, intVal); long longVal = mapMessage.getLong("long-type"); assertEquals(56652L, longVal); Object objectVal = mapMessage.getObject("object-type"); Object origVal = new String("VVVV"); assertTrue(objectVal.equals(origVal)); short shortVal = mapMessage.getShort("short-type"); assertEquals((short) 333, shortVal); String strVal = mapMessage.getString("string-type"); assertEquals(TEXT, strVal); }
Float floatVal = mapMessage.getFloat("afloat"); assertTrue(floatVal.equals(Float.valueOf(4.5F))); assertEquals(40, mapMessage.getInt("aint")); assertEquals(80L, mapMessage.getLong("along")); assertEquals(65, mapMessage.getShort("ashort"));
@Override protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException { super.assertEquivalent(m, mode, redelivery); MapMessage map = (MapMessage) m; ProxyAssertSupport.assertTrue(map.getBoolean("boolean1")); ProxyAssertSupport.assertEquals(map.getChar("char1"), 'c'); ProxyAssertSupport.assertEquals(map.getDouble("double1"), 1.0D, 0.0D); ProxyAssertSupport.assertEquals(map.getFloat("float1"), 2.0F, 0.0F); ProxyAssertSupport.assertEquals(map.getInt("int1"), 3); ProxyAssertSupport.assertEquals(map.getLong("long1"), 4L); ProxyAssertSupport.assertEquals(map.getObject("object1"), obj); ProxyAssertSupport.assertEquals(map.getShort("short1"), (short) 5); ProxyAssertSupport.assertEquals(map.getString("string1"), "stringvalue"); } }
ProxyAssertSupport.assertEquals(myByte, m2.getByte("myByte")); ProxyAssertSupport.assertEquals(myShort, m2.getShort("myShort")); ProxyAssertSupport.assertEquals(myInt, m2.getInt("myInt")); ProxyAssertSupport.assertEquals(myLong, m2.getLong("myLong")); ProxyAssertSupport.assertEquals(myFloat, m2.getFloat("myFloat"), 0); m2.getInt("myBool"); ProxyAssertSupport.fail(); } catch (MessageFormatException e) { ProxyAssertSupport.assertEquals(myByte, m2.getInt("myByte")); ProxyAssertSupport.assertEquals(myByte, m2.getLong("myByte")); ProxyAssertSupport.assertEquals(String.valueOf(myByte), m2.getString("myByte")); ProxyAssertSupport.assertEquals(myShort, m2.getInt("myShort")); ProxyAssertSupport.assertEquals(myShort, m2.getLong("myShort")); ProxyAssertSupport.assertEquals(String.valueOf(myShort), m2.getString("myShort")); m2.getInt("myLong"); ProxyAssertSupport.fail(); } catch (MessageFormatException e) { m2.getInt("myFloat"); ProxyAssertSupport.fail(); } catch (MessageFormatException e) { m2.getInt("myDouble"); ProxyAssertSupport.fail(); } catch (MessageFormatException e) {
Float floatVal = mapMessage.getFloat("afloat"); assertTrue(floatVal.equals(Float.valueOf(4.5F))); assertEquals(40, mapMessage.getInt("aint")); assertEquals(80L, mapMessage.getLong("along")); assertEquals(65, mapMessage.getShort("ashort"));