Package javax.jms

Examples of javax.jms.StreamMessage


    }

    private static Message listToMessage(List<?> value, Session session)
        throws JMSException
    {
        StreamMessage sMsg = session.createStreamMessage();

        for (Iterator<?> iter = value.iterator(); iter.hasNext();)
        {
            Object o = iter.next();
            if (validateStreamMessageType(o))
            {
                sMsg.writeObject(o);
            }
            else
            {
                throw new MessageFormatException(String.format(
                    "Invalid type passed to StreamMessage: %s . Allowed types are: "
View Full Code Here


        else if (source instanceof StreamMessage)
        {
            List<Object> result = new ArrayList<Object>();
            try
            {
                StreamMessage sMsg = (StreamMessage) source;
                Object obj;
                while ((obj = sMsg.readObject()) != null)
                {
                    result.add(obj);
                }
            }
            catch (MessageEOFException eof)
View Full Code Here

                }
            }
        }
        else if (message instanceof StreamMessage)
        {
            StreamMessage sMsg = (StreamMessage) message;
            sMsg.reset();

            ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
            byte[] buffer = new byte[4096];
            int len;

            while ((len = sMsg.readBytes(buffer)) != -1)
            {
                baos.write(buffer, 0, len);
            }

            return baos.toByteArray();
View Full Code Here

   }


   public void testCopyOnForeignStreamMessage() throws JMSException
   {
      StreamMessage foreignStreamMessage = new SimpleJMSStreamMessage();
      foreignStreamMessage.writeByte((byte)1);
      foreignStreamMessage.writeByte((byte)2);
      foreignStreamMessage.writeByte((byte)3);

      JBossStreamMessage copy = new JBossStreamMessage(foreignStreamMessage, 0);

      ensureEquivalent(foreignStreamMessage, copy);
   }
View Full Code Here

     * @param target the message to populate
     * @throws JMSException for any error
     */
    protected void populate(Message source, Message target)
        throws JMSException {
        StreamMessage from = (StreamMessage) source;
        StreamMessage to = (StreamMessage) target;

        // populate header
        super.populate(from, to);

        // populate body
        from.reset()// make sure the message can be read
        try {
            while (true) {
                Object object = from.readObject();
                to.writeObject(object);
            }
        } catch (MessageEOFException ignore) {
            // all done
        }
    }
View Full Code Here

            throw new JMSException(
                    "Expected List body for StreamMessage with JMSMessageID="
                    + message.getJMSMessageID()
                    + " but got type " + body.getClass().getName());
        }
        StreamMessage msg = (StreamMessage) message;
        List list = (List) body;
        for (Iterator i = list.iterator(); i.hasNext();) {
            Object value = i.next();
            msg.writeObject(value);
        }
    }
View Full Code Here

     * @param message the message
     * @return the body of the message
     * @throws JMSException for any JMS error
     */
    protected Object getBody(Message message) throws JMSException {
        StreamMessage msg = (StreamMessage) message;
        msg.reset();
        List result = new ArrayList();
        while (true) {
            try {
                Object value = msg.readObject();
                result.add(value);
            } catch (MessageEOFException exception) {
                break;
            }
        }
View Full Code Here

     
    jmsTemplate.send(requestQ, mc);
    System.out.println("Message Sent...");             
   
    String filter = "JMSCorrelationID = '" + sentMessage.getJMSMessageID() + "'";
    StreamMessage smsg = (StreamMessage)jmsTemplate.receiveSelected(replyQ, filter);
    System.out.println("Conf = " + smsg.readLong());
  }
View Full Code Here

      //without access to JNDI, must use replyto in jms header
     
      //shorter code than using a jmstemplate because no need to create a messageCreator
      //alternative would be to use a messagelistener and wire a jmstemplate to the class for sending result
      MessageProducer sender = session.createProducer(message.getJMSReplyTo());
      StreamMessage smsg = session.createStreamMessage();
      smsg.setJMSCorrelationID(message.getJMSMessageID());
      smsg.writeLong(conf);
      sender.send(smsg);
  }
View Full Code Here

        try {
            System.out.println("Message Received From " + message.getStringProperty("username"));
            TextMessage msg = (TextMessage)message;
            System.out.println(msg.getText());
            long conf = 98765;
            StreamMessage smsg = session.createStreamMessage();
            smsg.writeLong(conf);
            QueueSender sender = session.createSender((Queue)message.getJMSReplyTo());
            sender.send(smsg);
           
            System.out.println("Waiting for messages...");
      } catch (Exception e) {
View Full Code Here

TOP

Related Classes of javax.jms.StreamMessage

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.