Package org.apache.qpid.jms

Examples of org.apache.qpid.jms.ListMessage


        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
        MessageProducer producer = session.createProducer(queue);

        ListMessage m = ((org.apache.qpid.jms.Session)session).createListMessage();
        m.setIntProperty("Id", 987654321);
        m.setStringProperty("name", "Widget");
        m.setDoubleProperty("price", 0.99);

        List<String> colors = new ArrayList<String>();
        colors.add("red");
        colors.add("green");
        colors.add("white");
        m.add(colors);

        Map<String,Double> dimensions = new HashMap<String,Double>();
        dimensions.put("length",10.2);
        dimensions.put("width",5.1);
        dimensions.put("depth",2.0);
        m.add(dimensions);

        List<List<Integer>> parts = new ArrayList<List<Integer>>();
        parts.add(Arrays.asList(new Integer[] {1,2,5}));
        parts.add(Arrays.asList(new Integer[] {8,2,5}));
        m.add(parts);

        Map<String,Object> specs = new HashMap<String,Object>();
        specs.put("colours", colors);
        specs.put("dimensions", dimensions);
        specs.put("parts", parts);
        m.add(specs);

        producer.send((Message)m);
  System.out.println("Sent: " + m);
        connection.close();
    }
View Full Code Here


        Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
        MessageConsumer consumer = session.createConsumer(queue);

  if (args[0].equals("-l")) {
    System.out.println("Receiving as ListMessage");
          ListMessage m = (ListMessage)consumer.receive();
          System.out.println(m);
    System.out.println("==========================================");
    System.out.println("Printing list contents:");
    Iterator i = m.iterator();
    while(i.hasNext())
      System.out.println(i.next());
  }
  else if (args[0].equals("-m")) {
    System.out.println("Receiving as MapMessage");
          MapMessage m = (MapMessage)consumer.receive();
          System.out.println(m);
    System.out.println("==========================================");
    System.out.println("Printing map contents:");
    Enumeration keys = m.getMapNames();
    while(keys.hasMoreElements()) {
      String key = (String)keys.nextElement();
      System.out.println(key + " => " + m.getObject(key));
    }
  }
  else if (args[0].equals("-s")) {
    System.out.println("Receiving as StreamMessage");
          StreamMessage m = (StreamMessage)consumer.receive();
          System.out.println(m);
    System.out.println("==========================================");
    System.out.println("Printing stream contents:");
    try {
      while(true)
        System.out.println(m.readObject());
    }
    catch (MessageEOFException e) {
      // DONE
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.qpid.jms.ListMessage

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.