static protected MapMessage createMapMessage() throws JMSException { MapMessage mapMessage = new ActiveMQMapMessage(); mapMessage.setString("name", "Arnold"); mapMessage.setInt("age", 97); mapMessage.setDouble("xyz", 89686.564); mapMessage.setBoolean("good", true); return mapMessage; }
final Object v = entry.getValue(); if (v instanceof String) { message.setString(name, (String) v); } else if (v instanceof Long) { message.setLong(name, (Long) v);
@org.junit.Ignore public void testSendMapToQueue() throws Exception { final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class); runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER); runner.setProperty(JmsProperties.URL, "tcp://localhost:61616"); runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE); runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing"); runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO); WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true); final Session jmsSession = wrappedProducer.getSession(); final MessageProducer producer = wrappedProducer.getProducer(); final MapMessage message = jmsSession.createMapMessage(); message.setString("foo!", "bar"); message.setString("bacon", "meat"); producer.send(message); jmsSession.commit(); producer.close(); jmsSession.close(); }
public void setString(String name, String value) throws JMSException { ((MapMessage) message).setString(name, value); } }
@Override public void setString(final String name, final String value) throws JMSException { message.setString(name, value); }
public void setString(String name, String value) throws JMSException { ((MapMessage) message).setString(name, value); } }
/** * Set * @param name The name * @param value The value * @exception JMSException Thrown if an error occurs */ public void setString(final String name, final String value) throws JMSException { if (_log.isTraceEnabled()) { _log.trace("setString(" + name + ", " + value + ")"); } ((MapMessage)_message).setString(name, value); } }
private void notifyProcessed(String dataset, String lastSequenceId) throws JMSException { MapMessage message = producer.createMapMessage(); message.setString("dataset", dataset); message.setString("sequenceId", lastSequenceId); message.setString("consumerUuid", getConsumerUuid()); producer.send(message); }
public void sendMessage(final Map<String, Serializable> properties, final String bodyId) throws JMSException { final MapMessage message = session.createMapMessage(); for (final Map.Entry<String, Serializable> property : properties.entrySet()) { message.setObjectProperty(property.getKey(), property.getValue()); } message.setString("body-id", bodyId); message.setJMSExpiration(System.currentTimeMillis() + timeout); producer.send(message); } }
public void sendMessage(final Map<String, Serializable> properties, final String bodyId) throws JMSException { final MapMessage message = session.createMapMessage(); for (final Map.Entry<String, Serializable> property : properties.entrySet()) { message.setObjectProperty(property.getKey(), property.getValue()); } message.setString("body-id", bodyId); message.setJMSExpiration(System.currentTimeMillis() + timeout); producer.send(message); } }
/** * Set * * @param name The name * @param value The value * @throws JMSException Thrown if an error occurs */ @Override public void setString(final String name, final String value) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setString(" + name + ", " + value + ")"); } ((MapMessage) message).setString(name, value); } }
/** * Set * * @param name The name * @param value The value * @throws JMSException Thrown if an error occurs */ @Override public void setString(final String name, final String value) throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("setString(" + name + ", " + value + ")"); } ((MapMessage) message).setString(name, value); } }
protected Message makeMessage(Session session, ModelService modelService, Map<String, Object> context) throws GenericServiceException, JMSException { List<String> outParams = modelService.getParameterNames(ModelService.OUT_PARAM, false); if (UtilValidate.isNotEmpty(outParams)) throw new GenericServiceException("JMS service cannot have required OUT parameters; no parameters will be returned."); String xmlContext = null; try { if (Debug.verboseOn()) Debug.logVerbose("Serializing Context --> " + context, module); xmlContext = JmsSerializer.serialize(context); } catch (SerializeException | IOException e) { throw new GenericServiceException("Cannot serialize context.", e); } MapMessage message = session.createMapMessage(); message.setString("serviceName", modelService.invoke); message.setString("serviceContext", xmlContext); return message; }
@Override public final void getNext(CAS aCAS) throws IOException, CollectionException { try { DataElement nextElement = getNextFromSource(); MapMessage message = producer.createMapMessage(); message.setString("dataset", getDataset()); message.setString("sequenceId", nextElement.getSequenceId()); message.setInt("stageId", getStageId()); producer.send(message); topics.add(nextElement.getSequenceId()); count++; persistence.updateExperimentMeta(getUUID(), count); } catch (Exception e) { throw new CollectionException(e); } }
@Test public void testNullValue() throws Exception { MapMessage m = session.createMapMessage(); m.setString("nullValue", null); queueProd.send(m); MapMessage rm = (MapMessage) queueCons.receive(2000); ProxyAssertSupport.assertNotNull(rm); ProxyAssertSupport.assertNull(rm.getString("nullValue")); }
@Test public void testCopyOnForeignMapMessage() throws JMSException { ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000); ClientSession session = new FakeSession(clientMessage); MapMessage foreignMapMessage = new SimpleJMSMapMessage(); foreignMapMessage.setInt("int", 1); foreignMapMessage.setString("string", "test"); ActiveMQMapMessage copy = new ActiveMQMapMessage(foreignMapMessage, session); MessageHeaderTestBase.ensureEquivalent(foreignMapMessage, copy); }
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"); }
/** * Send a <code>MapMessage</code> with 2 Java primitives in its body (a <code> * String</code> and a <code>double</code>). * <br /> * Receive it and test that the values of the primitives of the body are correct */ @Test public void testMapMessage_2() { try { MapMessage message = senderSession.createMapMessage(); message.setString("name", "pi"); message.setDouble("value", 3.14159); sender.send(message); Message m = receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue("The message should be an instance of MapMessage.\n", m instanceof MapMessage); MapMessage msg = (MapMessage) m; Assert.assertEquals("pi", msg.getString("name")); Assert.assertEquals(3.14159, msg.getDouble("value"), 0); } catch (JMSException e) { fail(e); } }