Package javax.jms

Examples of javax.jms.ObjectMessage


   {
      TestSerializable obj = new TestSerializable();

      obj.str = "abcdefg";

      ObjectMessage m1 = queueProducerSession.createObjectMessage(obj);

      queueProducer.send(HornetQServerTestCase.queue1, m1);

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

      ProxyAssertSupport.assertNotNull(m2);

      TestSerializable obj2 = (TestSerializable)m2.getObject();

      ProxyAssertSupport.assertEquals(obj.str, obj2.str);

      ObjectMessage m3 = queueProducerSession.createObjectMessage();

      m3.setObject(obj);

      queueProducer.send(HornetQServerTestCase.queue1, m3);

      obj.str = "xyz123";

      ObjectMessage m4 = (ObjectMessage)queueConsumer.receive(2000);

      ProxyAssertSupport.assertNotNull(m4);

      TestSerializable obj3 = (TestSerializable)m4.getObject();

      ProxyAssertSupport.assertEquals("abcdefg", obj3.str);

      try
      {
         m4.setObject(obj);
         ProxyAssertSupport.fail();
      }
      catch (MessageNotWriteableException e)
      {
      }

      m4.clearBody();

      m4.setObject(obj);

      TestSerializable obj4 = (TestSerializable)m4.getObject();

      ProxyAssertSupport.assertNotNull(obj4);

   }
View Full Code Here


         to1.text = "hello2";

         TestObject to3 = new TestObject();
         to1.text = "hello3";

         ObjectMessage om1 = s.createObjectMessage();
         om1.setObject(to1);

         ObjectMessage om2 = s.createObjectMessage();
         om2.setObject(to2);

         ObjectMessage om3 = s.createObjectMessage();
         om3.setObject(to3);

         // send to topic
         publisher.send(om1);

         publisher.send(om2);

         publisher.send(om3);

         ObjectMessage rm1 = (ObjectMessage)sub.receive(HornetQServerTestCase.MAX_TIMEOUT);

         ObjectMessage rm2 = (ObjectMessage)sub.receive(HornetQServerTestCase.MAX_TIMEOUT);

         ObjectMessage rm3 = (ObjectMessage)sub.receive(HornetQServerTestCase.MAX_TIMEOUT);

         ProxyAssertSupport.assertNotNull(rm1);

         TestObject ro1 = (TestObject)rm1.getObject();

         ProxyAssertSupport.assertEquals(to1.text, ro1.text);
         ProxyAssertSupport.assertNotNull(rm1);

         TestObject ro2 = (TestObject)rm2.getObject();

         ProxyAssertSupport.assertEquals(to2.text, ro2.text);

         ProxyAssertSupport.assertNotNull(rm2);

         TestObject ro3 = (TestObject)rm3.getObject();

         ProxyAssertSupport.assertEquals(to3.text, ro3.text);
      }
      finally
      {
View Full Code Here

      ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
      try
      {
         queueProd.setDeliveryMode(DeliveryMode.PERSISTENT);

         ObjectMessage om = (ObjectMessage)message;

         SomeObject testObject = new SomeObject(3, 7);

         ClassLoader testClassLoader = ObjectMessageTest.newClassLoader(testObject.getClass());

         om.setObject(testObject);

         queueProd.send(message);

         Thread.currentThread().setContextClassLoader(testClassLoader);

         ObjectMessage r = (ObjectMessage)queueCons.receive();

         Object testObject2 = r.getObject();

         ProxyAssertSupport.assertEquals("org.hornetq.jms.tests.message.SomeObject", testObject2.getClass().getName());
         ProxyAssertSupport.assertNotSame(testObject, testObject2);
         ProxyAssertSupport.assertNotSame(testObject.getClass(), testObject2.getClass());
         ProxyAssertSupport.assertNotSame(testObject.getClass().getClassLoader(), testObject2.getClass()
View Full Code Here

      vectorOnMessage.add("world!");
      ((ObjectMessage)message).setObject(vectorOnMessage);

      queueProd.send(message);

      ObjectMessage r = (ObjectMessage)queueCons.receive(5000);
      ProxyAssertSupport.assertNotNull(r);

      java.util.Vector v2 = (java.util.Vector)r.getObject();

      ProxyAssertSupport.assertEquals(vectorOnMessage.get(0), v2.get(0));
   }
View Full Code Here

      ProxyAssertSupport.assertEquals(vectorOnMessage.get(0), v2.get(0));
   }

   public void testObjectIsolation() throws Exception
   {
      ObjectMessage msgTest = session.createObjectMessage();
      ArrayList list = new ArrayList();
      list.add("hello");
      msgTest.setObject(list);

      list.clear();

      list = (ArrayList)msgTest.getObject();

      ProxyAssertSupport.assertEquals(1, list.size());
      ProxyAssertSupport.assertEquals("hello", list.get(0));

      list.add("hello2");

      msgTest.setObject(list);

      list.clear();

      list = (ArrayList)msgTest.getObject();

      ProxyAssertSupport.assertEquals(2, list.size());
      ProxyAssertSupport.assertEquals("hello", list.get(0));
      ProxyAssertSupport.assertEquals("hello2", list.get(1));

      msgTest.setObject(list);
      list.add("hello3");
      msgTest.setObject(list);

      list = (ArrayList)msgTest.getObject();
      ProxyAssertSupport.assertEquals(3, list.size());
      ProxyAssertSupport.assertEquals("hello", list.get(0));
      ProxyAssertSupport.assertEquals("hello2", list.get(1));
      ProxyAssertSupport.assertEquals("hello3", list.get(2));

      list = (ArrayList)msgTest.getObject();

      list.clear();

      queueProd.send(msgTest);

      msgTest = (ObjectMessage)queueCons.receive(5000);

      list = (ArrayList)msgTest.getObject();

      ProxyAssertSupport.assertEquals(3, list.size());
      ProxyAssertSupport.assertEquals("hello", list.get(0));
      ProxyAssertSupport.assertEquals("hello2", list.get(1));
      ProxyAssertSupport.assertEquals("hello3", list.get(2));
View Full Code Here

   @Override
   protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException
   {
      super.assertEquivalent(m, mode, redelivery);

      ObjectMessage obj = (ObjectMessage)m;

      ProxyAssertSupport.assertNotNull(obj.getObject());
      ProxyAssertSupport.assertEquals(obj.getObject(), testObj);
   }
View Full Code Here

   }

   public void testReadOnEmptyObjectMessage() throws Exception
   {
      ObjectMessage obm = (ObjectMessage)message;
      ProxyAssertSupport.assertNull(obm.getObject());

      queueProd.send(message);
      ObjectMessage r = (ObjectMessage)queueCons.receive();

      ProxyAssertSupport.assertNull(r.getObject());

   }
View Full Code Here

   @Override
   protected void prepareMessage(final Message m) throws JMSException
   {
      super.prepareMessage(m);

      ObjectMessage om = (ObjectMessage)m;
      om.setObject("this is the serializable object");

   }
View Full Code Here

   @Override
   protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException
   {
      super.assertEquivalent(m, mode, redelivery);

      ObjectMessage om = (ObjectMessage)m;
      ProxyAssertSupport.assertEquals("this is the serializable object", om.getObject());
   }
View Full Code Here

        final TextMessage message = session.createTextMessage(msg);
        this.sendMessage(message, destination, replyDestination);
    }

    public void sendObjectMessage(final Serializable msg, final Destination destination, final Destination replyDestination) throws JMSException {
        final ObjectMessage message = session.createObjectMessage();
        message.setObject(msg);
        this.sendMessage(message, destination, replyDestination);
    }
View Full Code Here

TOP

Related Classes of javax.jms.ObjectMessage

Copyright © 2018 www.massapicom. 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.