Package javax.jms

Examples of javax.jms.ObjectMessage


        Connection connection = null;
        try {
            connection = connectionFactory.createConnection();
            final javax.jms.Session session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
            final MessageProducer producer = session.createProducer(smtpQueue);
            final ObjectMessage jmsMessage = session.createObjectMessage(mailMessage);
            producer.send(jmsMessage);
        } catch (final JMSException jmse) {
            throw new RuntimeException("Could not deliver mail message to the outgoing queue", jmse);
        } finally {
            close(connection);
View Full Code Here


         this.num = num;
      }

      public synchronized void onMessage(final Message m)
      {
         ObjectMessage om = (ObjectMessage)m;

         try
         {
            Wibble2 w = (Wibble2)om.getObject();
         }
         catch (Exception e)
         {
            failed = true;
         }
View Full Code Here

            byte[] blah = new byte[10000];
            String str = new String(blah);

            Wibble2 w = new Wibble2();
            w.s = str;
            ObjectMessage om = sSend.createObjectMessage(w);

            prod.send(om);
         }

         l1.waitForMessages();
View Full Code Here

         MessageConsumer cons = sess.createConsumer(HornetQServerTestCase.queue1);

         TestMessage tm = new TestMessage(123, false);

         ObjectMessage om = sess.createObjectMessage();

         om.setObject(tm);

         conn.start();

         prod.send(om);

         ObjectMessage om2 = (ObjectMessage)cons.receive(1000);

         ProxyAssertSupport.assertNotNull(om2);

         TestMessage tm2 = (TestMessage)om2.getObject();

         ProxyAssertSupport.assertEquals(123, tm2.getID());

         conn.close();
      }
View Full Code Here

public class ExampleListener implements MessageListener {

  @Override
  public void onMessage(Message arg0) {
    ObjectMessage tm = (ObjectMessage) arg0;
    try {
      Osoba o = (Osoba) tm.getObject();
      System.out.println(o.imie);
      System.out.println(arg0.getStringProperty("imie"));
    } catch (JMSException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

  public void simpleSend() {
    this.jmsTemplate.send(this.queue, new MessageCreator() {
      public Message createMessage(Session session) throws JMSException {
        Osoba osoba = new Osoba();
        osoba.imie = "miro";
        ObjectMessage createObjectMessage = session.createObjectMessage(osoba);
        if (at.incrementAndGet() % 2 == 0) {
          createObjectMessage.setStringProperty("imie", "maja");
        } else {
          createObjectMessage.setStringProperty("imie", "mirek");
        }

        return createObjectMessage;
      }
    });
View Full Code Here

 
  @TransactionAttribute(TransactionAttributeType.REQUIRED)   
  public void onMessage(Message message) {
    try {
      System.out.println("Przetwarzam wiadomosc "+new Date());
      ObjectMessage objectMessage = (ObjectMessage) message;
      HashMap<String, String> mapa = (HashMap<String, String>) objectMessage
          .getObject();
      String tytul = mapa.get("tytul").toString();
      String adres = mapa.get("adres").toString();
      String tresc = mapa.get("tresc").toString();
      System.out.println(tytul);
View Full Code Here

         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);
         ProxyAssertSupport.assertEquals("aardvark", sm2.readString());

         TextMessage tm2 = (TextMessage)theConsumer.receive(1500);
View Full Code Here

  protected Command extractCommand(Message message) {
    Command command = null;
    if (message instanceof ObjectMessage) {
      try {
        log.debug("deserializing command from jms message...");
        ObjectMessage objectMessage = (ObjectMessage)message;
        Serializable object = objectMessage.getObject();
        if (object== null) {
          log.warn("ignoring null message");
        } else if (object instanceof Command) {
          command = (Command) object;
        } else {
View Full Code Here

                                                          System.currentTimeMillis(),
                                                          (byte)4,
                                                          1000);
      ClientSession session = new FakeSession(clientMessage);

      ObjectMessage foreignObjectMessage = new SimpleJMSObjectMessage();

      HornetQObjectMessage copy = new HornetQObjectMessage(foreignObjectMessage, session);

      MessageHeaderTestBase.ensureEquivalent(foreignObjectMessage, copy);
   }
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.