Examples of MapMessage


Examples of javax.jms.MapMessage

      messageContext.setRollbackOnly();
      return;
    }
    try {
      // extract contents
      MapMessage invoiceMessage = (MapMessage) message;
      int orderId = invoiceMessage.getInt("orderId");
      float amount = invoiceMessage.getFloat("amount");

      // populate invoice with contents
      Invoice inv = new Invoice();
      inv.setOrderId(orderId);
      inv.setAmount(amount);
View Full Code Here

Examples of javax.jms.MapMessage

      // create a session
      Session session =
          connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
      try {
        // create the message
        MapMessage invoiceMessage = session.createMapMessage();
        invoiceMessage.setInt("orderId", orderId);
        invoiceMessage.setFloat("amount", amount);

        // send it!
        MessageProducer producer = session.createProducer(invoiceQueue);
        producer.send(invoiceMessage);
View Full Code Here

Examples of javax.jms.MapMessage

      // create a session
      Session session =
          connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
      try {
        // create the message
        MapMessage message = session.createMapMessage();
        message.setString("customerId", customerId);

        // send it!
        MessageProducer producer = session.createProducer(shippingQueue);
        producer.send(message);
View Full Code Here

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 = cf.createConnection();
         theOtherConn.start();

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

         MessageConsumer theConsumer = sessReceive.createConsumer(queue2);

         Message m2 = theConsumer.receive(1500);

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

         assertNotNull(m2);

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

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

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

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

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

Examples of javax.jms.MapMessage

        
         MessageProducer prod = sess.createProducer(queue);
        
         prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         
         MapMessage m = sess.createMapMessage();
        
         JBossMessage check1 = ((MessageProxy)m).getMessage();
        
         m.setString("map_entry", "map_value");        
         m.setStringProperty("property_entry", "property_value");  
        
         m.setJMSReplyTo(new JBossQueue("wibble"));
        
         JBossMessage check2 = ((MessageProxy)m).getMessage();
        
         checkSameUnderlyingMessage(check1, check2, true);
         checkSameBody(check1, check2, true);
        
         prod.send(m);
        
         JBossMessage check3 = ((MessageProxy)m).getMessage();
        
         //Underlying message should be the same before and after
         checkSameUnderlyingMessage(check2, check3, true);
         checkSameBody(check2, check3, true);
        
         prod.send(m);
        
         JBossMessage check4 = ((MessageProxy)m).getMessage();
        
         assertFalse(check3.getMessageID() == check4.getMessageID());
        
         //The underlying message should now be different
         checkSameUnderlyingMessage(check3, check4, false);
        
         //But the body should be the same
         checkSameBody(check3, check4, true);
        
         prod.send(m);
        
         JBossMessage check5 = ((MessageProxy)m).getMessage();
        
         // The message should be different
         assertFalse(check4.getMessageID() == check5.getMessageID());
        
         checkSameUnderlyingMessage(check4, check5, false);
        
         //But the body should be the same
         checkSameBody(check4, check5, true);
        
         //Now set another header
        
         m.setJMSType("type123");
        
         JBossMessage check6 = ((MessageProxy)m).getMessage();
        
        
         //The message should be different
         checkSameUnderlyingMessage(check5, check6, false);
        
         //But the body should be the same
         checkSameBody(check5, check6, true);
        
         prod.send(m);
        
         JBossMessage check7 = ((MessageProxy)m).getMessage();
                 
         //The message should be the same
        
         checkSameUnderlyingMessage(check6, check7, true);
        
         // But the body should be the same
         checkSameBody(check6, check7, true);
        
         // Set the body
         m.setString("key1", "blah");
        
         JBossMessage check8 = ((MessageProxy)m).getMessage();
        
         //The message should be the same
        
View Full Code Here

Examples of javax.jms.MapMessage

        
         MessageProducer prod = sess.createProducer(queue);
        
         prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         
         MapMessage m = sess.createMapMessage();
        
         MessageConsumer cons = sess.createConsumer(queue);
        
         prod.send(m);
        
         m = (MapMessage)cons.receive(2000);
        
         assertNotNull(m);
                          
         JBossMessage check1 = ((MessageProxy)m).getMessage();        
        
         prod.send(m);
        
         JBossMessage check3 = ((MessageProxy)m).getMessage();
        
         //Underlying message should be different
         checkSameUnderlyingMessage(check1, check3, true);
         checkSameBody(check1, check3, true);
        
         prod.send(m);
        
         JBossMessage check4 = ((MessageProxy)m).getMessage();
        
         assertFalse(check3.getMessageID() == check4.getMessageID());
        
         //The underlying message should now be different
         checkSameUnderlyingMessage(check3, check4, false);
        
         //But the body should be the same
         checkSameBody(check3, check4, true);
        
         prod.send(m);
        
         JBossMessage check5 = ((MessageProxy)m).getMessage();
        
         // The message should be different
         assertFalse(check4.getMessageID() == check5.getMessageID());
        
         checkSameUnderlyingMessage(check4, check5, false);
        
         //But the body should be the same
         checkSameBody(check4, check5, true);
        
         //Now set another header
        
         m.setJMSType("type123");
        
         JBossMessage check6 = ((MessageProxy)m).getMessage();
        
        
         //The message should be different
         checkSameUnderlyingMessage(check5, check6, false);
        
         //But the body should be the same
         checkSameBody(check5, check6, true);
        
         prod.send(m);
        
         JBossMessage check7 = ((MessageProxy)m).getMessage();
                 
         //The message should be the same
        
         checkSameUnderlyingMessage(check6, check7, true);
        
         // But the body should be the same
         checkSameBody(check6, check7, true);
        
         // Set the body
         m.setString("key1", "blah");
        
         JBossMessage check8 = ((MessageProxy)m).getMessage();
        
         //The message should be the same
        
View Full Code Here

Examples of javax.jms.MapMessage

   }

   public void testMapMessage() throws Exception
   {
      log.info("+++ testMapMessage");
      MapMessage sent = session.createMapMessage();
      sent.setBoolean("Boolean", true);
      sent.setByte("Byte", (byte) 1);
      sent.setBytes("Bytes", "Bytes".getBytes());
      sent.setChar("Char", 'c');
      sent.setShort("Short", (short) 31415);
      sent.setInt("Int", 314159);
      sent.setLong("Long", 3141592653589793238L);
      sent.setDouble("Double", 3.1415926535897932384626433832795);
      sent.setFloat("Float", 3.141f);
      sent.setObject("Object", "31415926535897932384626433832795");
      sent.setString("String", "31415926535897932384626433832795");

      MapMessage recv = (MapMessage) sendRecMsg(sent);
      log.debug("recv: "+recv);
      assertTrue("Boolean == true", recv.getBoolean("Boolean") == true);
      assertTrue("Byte == 1", recv.getByte("Byte") == 1);
      assertTrue("Bytes == Bytes[]",
         Arrays.equals(recv.getBytes("Bytes"), "Bytes".getBytes()));
      assertTrue("Char == c", recv.getChar("Char") == 'c');
      assertTrue("Short == 314159", recv.getShort("Short") == 31415);
      assertTrue("Int == 314159", recv.getInt("Int") == 314159);
      assertTrue("Long == 3141592653589793238L",
         recv.getLong("Long") == 3141592653589793238L);
      assertTrue("Double == 3.1415926535897932384626433832795",
         recv.getDouble("Double") == 3.1415926535897932384626433832795);
      assertTrue("Float == true", recv.getFloat("Float") == 3.141f);
      assertTrue("Object == 31415926535897932384626433832795",
         recv.getObject("Object").equals("31415926535897932384626433832795"));
      assertTrue("String == 31415926535897932384626433832795",
         recv.getString("String").equals("31415926535897932384626433832795"));
   }
View Full Code Here

Examples of javax.jms.MapMessage

        if (msg != null) {
            try {
                if (msg instanceof TextMessage){
                    buffer.append(((TextMessage) msg).getText());
                } else if (msg instanceof MapMessage){
                    MapMessage mapm = (MapMessage) msg;
                    @SuppressWarnings("unchecked") // MapNames are Strings
                    Enumeration<String> enumb = mapm.getMapNames();
                    while(enumb.hasMoreElements()){
                        String name = enumb.nextElement();
                        Object obj = mapm.getObject(name);
                        buffer.append(name);
                        buffer.append(",");
                        buffer.append(obj.getClass().getCanonicalName());
                        buffer.append(",");
                        buffer.append(obj);
View Full Code Here

Examples of javax.jms.MapMessage

     */
    private final void handleLocateRequest(final Handle handle)
    {
        try
        {
            MapMessage response = _syncSession.createMapMessage();
            response.setStringProperty("x-amqp-0-10.app-id", "qmf2");
            response.setStringProperty("method", "indication");
            response.setStringProperty("qmf.opcode", "_agent_locate_response");
            response.setStringProperty("qmf.agent", _name);
            response.setStringProperty("qpid.subject", handle.getRoutingKey());
            setValue("_timestamp", System.currentTimeMillis()*1000000l);
            response.setObject("_values", mapEncode());
            sendResponse(handle, response);
        }
        catch (JMSException jmse)
        {
            _log.info("JMSException {} caught in handleLocateRequest()", jmse.getMessage());
View Full Code Here

Examples of javax.jms.MapMessage

     */
    public final void raiseException(final Handle handle, final String message)
    {
        try
        {
            MapMessage response = _syncSession.createMapMessage();
            response.setJMSCorrelationID(handle.getCorrelationId());
            response.setStringProperty("x-amqp-0-10.app-id", "qmf2");
            response.setStringProperty("method", "response");
            response.setStringProperty("qmf.opcode", "_exception");
            response.setStringProperty("qmf.agent", _name);
            response.setStringProperty("qpid.subject", handle.getRoutingKey());

            QmfData exception = new QmfData();
            exception.setValue("error_text", message);
            response.setObject("_values", exception.mapEncode());
            sendResponse(handle, response);
        }
        catch (JMSException jmse)
        {
            _log.info("JMSException {} caught in handleLocateRequest()", jmse.getMessage());
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.