Examples of MapMessage


Examples of javax.jms.MapMessage

         m.setStringProperty("p1", "aardvark");

         BytesMessage bm = sessSend.createBytesMessage();
         bm.writeObject("aardvark");

         MapMessage mm = sessSend.createMapMessage();
         mm.setString("s1", "aardvark");

         ObjectMessage om = sessSend.createObjectMessage();
         om.setObject("aardvark");

         StreamMessage sm = sessSend.createStreamMessage();
         sm.writeString("aardvark");

         TextMessage tm = sessSend.createTextMessage("aardvark");

         theProducer.send(m);
         theProducer.send(bm);
         theProducer.send(mm);
         theProducer.send(om);
         theProducer.send(sm);
         theProducer.send(tm);

         theConn.close();

         theOtherConn = JMSTestCase.cf.createConnection();
         theOtherConn.start();

         Session sessReceive = theOtherConn.createSession(false, Session.AUTO_ACKNOWLEDGE);

         MessageConsumer theConsumer = sessReceive.createConsumer(HornetQServerTestCase.queue1);

         Message m2 = theConsumer.receive(1500);

         log.trace("m2 is " + m2);

         ProxyAssertSupport.assertNotNull(m2);

         ProxyAssertSupport.assertEquals("aardvark", m2.getStringProperty("p1"));

         BytesMessage bm2 = (BytesMessage)theConsumer.receive(1500);
         ProxyAssertSupport.assertEquals("aardvark", bm2.readUTF());

         MapMessage mm2 = (MapMessage)theConsumer.receive(1500);
         ProxyAssertSupport.assertEquals("aardvark", mm2.getString("s1"));

         ObjectMessage om2 = (ObjectMessage)theConsumer.receive(1500);
         ProxyAssertSupport.assertEquals("aardvark", (String)om2.getObject());

         StreamMessage sm2 = (StreamMessage)theConsumer.receive(1500);
View Full Code Here

Examples of javax.jms.MapMessage

      super.tearDown();
   }

   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"));
   }
View Full Code Here

Examples of javax.jms.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");
   }
View Full Code Here

Examples of javax.jms.MapMessage

   @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"));
   }
View Full Code Here

Examples of javax.jms.MapMessage

                                                          0,
                                                          System.currentTimeMillis(),
                                                          (byte)4,
                                                          1000);
      ClientSession session = new FakeSession(clientMessage);
      MapMessage foreignMapMessage = new SimpleJMSMapMessage();
      foreignMapMessage.setInt("int", 1);
      foreignMapMessage.setString("string", "test");

      HornetQMapMessage copy = new HornetQMapMessage(foreignMapMessage, session);

      MessageHeaderTestBase.ensureEquivalent(foreignMapMessage, copy);
   }
View Full Code Here

Examples of javax.jms.MapMessage

   @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");
   }
View Full Code Here

Examples of javax.jms.MapMessage

   }

   public void testMapMessage() throws Exception
   {
      MapMessage m1 = queueProducerSession.createMapMessage();

      // Some arbitrary values
      boolean myBool = true;
      byte myByte = 13;
      short myShort = 15321;
      int myInt = 0x71ab6c80;
      long myLong = 0x20bf1e3fb6fa31dfL;
      float myFloat = Float.MAX_VALUE - 23465;
      double myDouble = Double.MAX_VALUE - 72387633;
      String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";

      m1.setBoolean("myBool", myBool);
      m1.setByte("myByte", myByte);
      m1.setShort("myShort", myShort);
      m1.setInt("myInt", myInt);
      m1.setLong("myLong", myLong);
      m1.setFloat("myFloat", myFloat);
      m1.setDouble("myDouble", myDouble);
      m1.setString("myString", myString);

      m1.setObject("myBool", new Boolean(myBool));
      m1.setObject("myByte", new Byte(myByte));
      m1.setObject("myShort", new Short(myShort));
      m1.setObject("myInt", new Integer(myInt));
      m1.setObject("myLong", new Long(myLong));
      m1.setObject("myFloat", new Float(myFloat));
      m1.setObject("myDouble", new Double(myDouble));
      m1.setObject("myString", myString);

      try
      {
         m1.setObject("myIllegal", new Object());
         ProxyAssertSupport.fail();
      }
      catch (javax.jms.MessageFormatException e)
      {
      }

      queueProducer.send(HornetQServerTestCase.queue1, m1);

      MapMessage m2 = (MapMessage)queueConsumer.receive(2000);

      ProxyAssertSupport.assertNotNull(m2);

      ProxyAssertSupport.assertEquals(myBool, m2.getBoolean("myBool"));
      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);
      ProxyAssertSupport.assertEquals(myDouble, m2.getDouble("myDouble"), 0);
      ProxyAssertSupport.assertEquals(myString, m2.getString("myString"));

      // Properties should now be read-only
      try
      {
         m2.setBoolean("myBool", myBool);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setByte("myByte", myByte);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setShort("myShort", myShort);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setInt("myInt", myInt);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setLong("myLong", myLong);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setFloat("myFloat", myFloat);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setDouble("myDouble", myDouble);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      try
      {
         m2.setString("myString", myString);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      ProxyAssertSupport.assertTrue(m2.itemExists("myBool"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myByte"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myShort"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myInt"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myLong"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myFloat"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myDouble"));
      ProxyAssertSupport.assertTrue(m2.itemExists("myString"));

      ProxyAssertSupport.assertFalse(m2.itemExists("sausages"));

      HashSet itemNames = new HashSet();
      Enumeration en = m2.getMapNames();
      while (en.hasMoreElements())
      {
         String propName = (String)en.nextElement();
         itemNames.add(propName);
      }

      ProxyAssertSupport.assertEquals(8, itemNames.size());

      ProxyAssertSupport.assertTrue(itemNames.contains("myBool"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myByte"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myShort"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myInt"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myLong"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myFloat"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myDouble"));
      ProxyAssertSupport.assertTrue(itemNames.contains("myString"));

      // Check property conversions

      // Boolean property can be read as String but not anything else

      ProxyAssertSupport.assertEquals(String.valueOf(myBool), m2.getString("myBool"));

      try
      {
         m2.getByte("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getShort("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getInt("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getLong("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getDouble("myBool");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // byte item can be read as short, int, long or String

      ProxyAssertSupport.assertEquals((short)myByte, m2.getShort("myByte"));
      ProxyAssertSupport.assertEquals((int)myByte, m2.getInt("myByte"));
      ProxyAssertSupport.assertEquals((long)myByte, m2.getLong("myByte"));
      ProxyAssertSupport.assertEquals(String.valueOf(myByte), m2.getString("myByte"));

      try
      {
         m2.getBoolean("myByte");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myByte");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getDouble("myByte");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // short item can be read as int, long or String

      ProxyAssertSupport.assertEquals((int)myShort, m2.getInt("myShort"));
      ProxyAssertSupport.assertEquals((long)myShort, m2.getLong("myShort"));
      ProxyAssertSupport.assertEquals(String.valueOf(myShort), m2.getString("myShort"));

      try
      {
         m2.getByte("myShort");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getBoolean("myShort");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myShort");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getDouble("myShort");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // int item can be read as long or String

      ProxyAssertSupport.assertEquals((long)myInt, m2.getLong("myInt"));
      ProxyAssertSupport.assertEquals(String.valueOf(myInt), m2.getString("myInt"));

      try
      {
         m2.getShort("myInt");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getByte("myInt");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getBoolean("myInt");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myInt");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getDouble("myInt");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // long item can be read as String

      ProxyAssertSupport.assertEquals(String.valueOf(myLong), m2.getString("myLong"));

      try
      {
         m2.getInt("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getShort("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getByte("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getBoolean("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getDouble("myLong");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // float can be read as double or String

      ProxyAssertSupport.assertEquals(String.valueOf(myFloat), m2.getString("myFloat"));
      ProxyAssertSupport.assertEquals((double)myFloat, m2.getDouble("myFloat"), 0);

      try
      {
         m2.getInt("myFloat");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getShort("myFloat");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getLong("myFloat");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getByte("myFloat");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getBoolean("myFloat");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      // double can be read as String

      ProxyAssertSupport.assertEquals(String.valueOf(myDouble), m2.getString("myDouble"));

      try
      {
         m2.getFloat("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getInt("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getShort("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getByte("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getBoolean("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      try
      {
         m2.getFloat("myDouble");
         ProxyAssertSupport.fail();
      }
      catch (MessageFormatException e)
      {
      }

      m2.clearBody();

      ProxyAssertSupport.assertFalse(m2.getMapNames().hasMoreElements());

      // Test String -> Numeric and bool conversions
      MapMessage m3 = (MapMessage)queueProducerSession.createMapMessage();

      m3.setString("myBool", String.valueOf(myBool));
      m3.setString("myByte", String.valueOf(myByte));
      m3.setString("myShort", String.valueOf(myShort));
      m3.setString("myInt", String.valueOf(myInt));
      m3.setString("myLong", String.valueOf(myLong));
      m3.setString("myFloat", String.valueOf(myFloat));
      m3.setString("myDouble", String.valueOf(myDouble));
      m3.setString("myIllegal", "xyz123");

      ProxyAssertSupport.assertEquals(myBool, m3.getBoolean("myBool"));
      ProxyAssertSupport.assertEquals(myByte, m3.getByte("myByte"));
      ProxyAssertSupport.assertEquals(myShort, m3.getShort("myShort"));
      ProxyAssertSupport.assertEquals(myInt, m3.getInt("myInt"));
      ProxyAssertSupport.assertEquals(myLong, m3.getLong("myLong"));
      ProxyAssertSupport.assertEquals(myFloat, m3.getFloat("myFloat"), 0);
      ProxyAssertSupport.assertEquals(myDouble, m3.getDouble("myDouble"), 0);

      m3.getBoolean("myIllegal");

      try
      {
         m3.getByte("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
      try
      {
         m3.getShort("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
      try
      {
         m3.getInt("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
      try
      {
         m3.getLong("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
      try
      {
         m3.getFloat("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
      try
      {
         m3.getDouble("myIllegal");
         ProxyAssertSupport.fail();
      }
      catch (NumberFormatException e)
      {
      }
View Full Code Here

Examples of javax.jms.MapMessage

   * @see MessageListener#onMessage(Message)
   */
  public void onMessage(Message message) {

    try {
      final MapMessage msg = (MapMessage) message;
      log.info("Nome: " + msg.getString("nome"));

      log.info("");

      log.info("Idade: " + msg.getLong("idade"));
    } catch (JMSException e) {
      log.error("", e);
    } catch (Exception e) {
      log.error("", e);
    }
View Full Code Here

Examples of javax.jms.MapMessage

      final TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      final TopicPublisher publisher = session.createPublisher(topic);

      final MapMessage message = session.createMapMessage();

      message.setString("nome", "Regis");
      message.setInt("idade", 23);

      publisher.send(message);

      // close resources
      publisher.close();
View Full Code Here

Examples of org.apache.logging.log4j.message.MapMessage

                        newMap.put(entry.getKey(), entry.getValue());
                    }
                }
            }
        }
        final MapMessage message = ((MapMessage) msg).newInstance(newMap);
        return new Log4jLogEvent(source.getLoggerName(), source.getMarker(), source.getFQCN(), source.getLevel(),
            message, source.getThrown(), source.getContextMap(), source.getContextStack(), source.getThreadName(),
            source.getSource(), source.getMillis());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.