message.setString(name, (String) v); } else if (v instanceof Long) { message.setLong(name, (Long) v); } else if (v instanceof Double) { message.setDouble(name, (Double) v);
public void setLong(String name, long value) throws JMSException { ((MapMessage) message).setLong(name, value); }
@Override public void setLong(final String name, final long value) throws JMSException { message.setLong(name, value); }
public void setLong(String name, long value) throws JMSException { ((MapMessage) message).setLong(name, value); }
/** * Set * @param name The name * @param value The value * @exception JMSException Thrown if an error occurs */ public void setLong(final String name, final long value) throws JMSException { if (_log.isTraceEnabled()) { _log.trace("setLong(" + name + ", " + value + ")"); } ((MapMessage)_message).setLong(name, value); }
/** * Set * * @param name The name * @param value The value * @throws JMSException Thrown if an error occurs */ @Override public void setLong(final String name, final long value) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setLong(" + name + ", " + value + ")"); } ((MapMessage) message).setLong(name, value); }
/** * Set * * @param name The name * @param value The value * @throws JMSException Thrown if an error occurs */ @Override public void setLong(final String name, final long value) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setLong(" + name + ", " + value + ")"); } ((MapMessage) message).setLong(name, value); }
private void mapToMapMessage(final Map<?, ?> map, MapMessage mapMessage) throws JMSException { for(Entry<?, ?> entry : map.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if(value instanceof String) { mapMessage.setString(key, (String)value); } else if(value instanceof Integer) { mapMessage.setInt(key, (Integer)value); } else if(value instanceof Long) { mapMessage.setLong(key, (Long)value); } else if(value instanceof Double) { mapMessage.setDouble(key, (Double)value); } else if(value instanceof Float) { mapMessage.setFloat(key, (Float)value); } else if(value instanceof Boolean) { mapMessage.setBoolean(key, (Boolean)value); } else if(value instanceof Short) { mapMessage.setShort(key, (Short)value); } else if(value instanceof Byte) { mapMessage.setByte(key, (Byte)value); } else if(value instanceof Character) { mapMessage.setChar(key, (Character)value); } else if(value instanceof byte[]) { mapMessage.setBytes(key, (byte[])value); } else { mapMessage.setString(key, value.toString()); } } }
private void mapToMapMessage(final Map<?, ?> map, MapMessage mapMessage) throws JMSException { for(Entry<?, ?> entry : map.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if(value instanceof String) { mapMessage.setString(key, (String)value); } else if(value instanceof Integer) { mapMessage.setInt(key, (Integer)value); } else if(value instanceof Long) { mapMessage.setLong(key, (Long)value); } else if(value instanceof Double) { mapMessage.setDouble(key, (Double)value); } else if(value instanceof Float) { mapMessage.setFloat(key, (Float)value); } else if(value instanceof Boolean) { mapMessage.setBoolean(key, (Boolean)value); } else if(value instanceof Short) { mapMessage.setShort(key, (Short)value); } else if(value instanceof Byte) { mapMessage.setByte(key, (Byte)value); } else if(value instanceof Character) { mapMessage.setChar(key, (Character)value); } else if(value instanceof byte[]) { mapMessage.setBytes(key, (byte[])value); } else { mapMessage.setString(key, value.toString()); } } }
private void mapToMapMessage(final Map<?, ?> map, MapMessage mapMessage) throws JMSException { for(Entry<?, ?> entry : map.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if(value instanceof String) { mapMessage.setString(key, (String)value); } else if(value instanceof Integer) { mapMessage.setInt(key, (Integer)value); } else if(value instanceof Long) { mapMessage.setLong(key, (Long)value); } else if(value instanceof Double) { mapMessage.setDouble(key, (Double)value); } else if(value instanceof Float) { mapMessage.setFloat(key, (Float)value); } else if(value instanceof Boolean) { mapMessage.setBoolean(key, (Boolean)value); } else if(value instanceof Short) { mapMessage.setShort(key, (Short)value); } else if(value instanceof Byte) { mapMessage.setByte(key, (Byte)value); } else if(value instanceof Character) { mapMessage.setChar(key, (Character)value); } else if(value instanceof byte[]) { mapMessage.setBytes(key, (byte[])value); } else { mapMessage.setString(key, value.toString()); } } }
else if (v instanceof Integer) jmsMessage.setInt(k, (Integer) v); else if (v instanceof Float) jmsMessage.setFloat(k, (Float) v); else if (v instanceof Long) jmsMessage.setLong(k, (Long) v); else if (v instanceof Double) jmsMessage.setDouble(k, (Double) v); else if (v instanceof String) jmsMessage.setString(k, (String) v);
/** * @see org.ikasan.framework.event.serialisation.JmsMessageEventSerialiser#toMessage(org.ikasan.framework.component.Event, javax.jms.Session) */ public MapMessage toMessage(Event event, Session session) throws JMSException { MapMessage mapMessage = session.createMapMessage(); List<Payload> payloads = event.getPayloads(); for (int i = 0; i < payloads.size(); i++) { Payload payload = payloads.get(i); mapMessage.setBytes(PAYLOAD_PREFIX + i + PAYLOAD_CONTENT_SUFFIX, payload.getContent()); mapMessage.setString(PAYLOAD_PREFIX + i + PAYLOAD_ID_SUFFIX, payload.getId()); //map any payload attributes for (String attributeName : payload.getAttributeNames()){ mapMessage.setString(PAYLOAD_PREFIX + i +ATTRIBUTE_PREFIX+attributeName, payload.getAttribute(attributeName)); } } mapMessage.setString(EVENT_FIELD_ID, event.getId()); mapMessage.setInt(EVENT_FIELD_PRIORITY, event.getPriority()); mapMessage.setLong(EVENT_FIELD_TIMESTAMP, event.getTimestamp().getTime()); return mapMessage; }
message.setString(name, (String) v); } else if (v instanceof Long) { message.setLong(name, (Long) v); } else if (v instanceof Double) { message.setDouble(name, (Double) v);
private void sendMapMessageUsingCoreJms(String queueName) throws Exception { Connection jmsConn = null; try { jmsConn = coreCf.createConnection(); Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE); MapMessage mapMessage = session.createMapMessage(); mapMessage.setBoolean("aboolean", true); mapMessage.setByte("abyte", (byte) 4); mapMessage.setBytes("abytes", new byte[]{4, 5}); mapMessage.setChar("achar", 'a'); mapMessage.setDouble("adouble", 4.4); mapMessage.setFloat("afloat", 4.5f); mapMessage.setInt("aint", 40); mapMessage.setLong("along", 80L); mapMessage.setShort("ashort", (short) 65); mapMessage.setString("astring", "hello"); Queue queue = session.createQueue(queueName); MessageProducer producer = session.createProducer(queue); producer.send(mapMessage); } finally { if (jmsConn != null) { jmsConn.close(); } } }
public static void setMapProperty(String name, Object value, MapMessage msg) throws JMSException { if (value == null || msg == null || name == null) return; if (value instanceof String) msg.setString(name, (String)value); else if (value instanceof Boolean) msg.setBoolean(name, (Boolean)value); else if (value instanceof Integer) msg.setInt(name, (Integer)value); else if (value instanceof Long) msg.setLong(name, (Long)value); else if (value instanceof Double) msg.setDouble(name, (Double)value); else if (value instanceof Byte) msg.setByte(name, (Byte)value); else if (value instanceof Float) msg.setFloat(name, (Float)value); else if (value instanceof Short) msg.setShort(name, (Short)value); else msg.setObject(name, value); }
@Test public void testResendWithMapMessagesOnly() throws Exception { conn = cf.createConnection(); conn.start(); Session sess = conn.createSession(true, Session.SESSION_TRANSACTED); ArrayList<Message> msgs = new ArrayList<>(); for (int i = 0; i < 1; i++) { MapMessage mm = sess.createMapMessage(); mm.setBoolean("boolean", true); mm.setByte("byte", (byte) 3); mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5}); mm.setChar("char", (char) 6); mm.setDouble("double", 7.0); mm.setFloat("float", 8.0f); mm.setInt("int", 9); mm.setLong("long", 10L); mm.setObject("object", new String("this is an object")); mm.setShort("short", (short) 11); mm.setString("string", "this is a string"); msgs.add(mm); MapMessage emptyMap = sess.createMapMessage(); msgs.add(emptyMap); } internalTestResend(msgs, sess); }
@Test public void testResendWithLargeMessage() throws Exception { conn = cf.createConnection(); conn.start(); Session sess = conn.createSession(true, Session.SESSION_TRANSACTED); ArrayList<Message> msgs = new ArrayList<>(); for (int i = 0; i < 10; i++) { BytesMessage bm = sess.createBytesMessage(); bm.setObjectProperty(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM, ActiveMQTestBase.createFakeLargeStream(2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE)); msgs.add(bm); MapMessage mm = sess.createMapMessage(); mm.setBoolean("boolean", true); mm.setByte("byte", (byte) 3); mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5}); mm.setChar("char", (char) 6); mm.setDouble("double", 7.0); mm.setFloat("float", 8.0f); mm.setInt("int", 9); mm.setLong("long", 10L); mm.setObject("object", new String("this is an object")); mm.setShort("short", (short) 11); mm.setString("string", "this is a string"); msgs.add(mm); msgs.add(sess.createTextMessage("hello" + i)); msgs.add(sess.createObjectMessage(new SomeSerializable("hello" + i))); } internalTestResend(msgs, sess); }
private void sendCompressedMapMessageUsingOpenWire() throws Exception { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE); final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination); MapMessage mapMessage = session.createMapMessage(); mapMessage.setBoolean("boolean-type", true); mapMessage.setByte("byte-type", (byte) 10); mapMessage.setBytes("bytes-type", TEXT.getBytes()); mapMessage.setChar("char-type", 'A'); mapMessage.setDouble("double-type", 55.3D); mapMessage.setFloat("float-type", 79.1F); mapMessage.setInt("int-type", 37); mapMessage.setLong("long-type", 56652L); mapMessage.setObject("object-type", new String("VVVV")); mapMessage.setShort("short-type", (short) 333); mapMessage.setString("string-type", TEXT); producer.send(mapMessage); }
private void sendMapMessageUsingOpenWire() 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); MapMessage mapMessage = session.createMapMessage(); mapMessage.setBoolean("aboolean", true); mapMessage.setByte("abyte", (byte) 4); mapMessage.setBytes("abytes", new byte[]{4, 5}); mapMessage.setChar("achar", 'a'); mapMessage.setDouble("adouble", 4.4); mapMessage.setFloat("afloat", 4.5f); mapMessage.setInt("aint", 40); mapMessage.setLong("along", 80L); mapMessage.setShort("ashort", (short) 65); mapMessage.setString("astring", "hello"); producer.send(mapMessage); }
@Override protected void prepareMessage(final Message m) throws JMSException { super.prepareMessage(m); MapMessage mm = (MapMessage) m; mm.setBoolean("boolean", true); mm.setByte("byte", (byte) 3); mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5}); mm.setChar("char", (char) 6); mm.setDouble("double", 7.0); mm.setFloat("float", 8.0f); mm.setInt("int", 9); mm.setLong("long", 10L); mm.setObject("object", new String("this is an object")); mm.setShort("short", (short) 11); mm.setString("string", "this is a string"); }