Package javax.jms

Examples of javax.jms.BytesMessage


            }
            int length = offset;
            if (this.contentReplacer != null)
               buf = this.contentReplacer.replace(buf, this.props);

            BytesMessage chunk = this.session.createBytesMessage();
            MessageHelper.copyProperties(this, chunk);

            chunk.writeBytes(buf, 0, length);
            if (length < bufSize)
               chunk.setBooleanProperty(XBConnectionMetaData.JMSX_GROUP_EOF, true);
            chunk.setLongProperty(XBConnectionMetaData.JMSX_GROUP_SEQ, count);
            chunk.reset();
            producer.send(dest, chunk);
            count++;
            if (length < bufSize)
               return;
         }           
      }
      catch (Exception ex) {
         if (count > 0) {
            BytesMessage chunk = session.createBytesMessage();
            chunk.setBooleanProperty(XBConnectionMetaData.JMSX_GROUP_EOF, true);
            chunk.setLongProperty(XBConnectionMetaData.JMSX_GROUP_SEQ, count);
            Enumeration eNum = chunk.getPropertyNames();
            while (eNum.hasMoreElements()) {
               String key = (String)eNum.nextElement();
               chunk.setObjectProperty(key, getObjectProperty(key));
            }
            chunk.setStringProperty(XBConnectionMetaData.JMSX_GROUP_EX, ex.getMessage());
            producer.send(dest, chunk);
         }
         if (ex instanceof JMSException)
            throw (JMSException)ex;
         throw new JMSException(ex.getMessage());
View Full Code Here


         else
            throw new XBException("feature.missing", "Handling of non XBStreamMessage types not implemented");
      }
      else if (msg instanceof BytesMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.BYTES);
         BytesMessage bytesMsg = (BytesMessage)msg;
         long length = bytesMsg.getBodyLength();
         if (length >= Integer.MAX_VALUE)
            throw new XBException("feature.missing", "Handling of big message not implemented");
         content = new byte[(int)length];
         bytesMsg.readBytes(content);
      }
      else if (msg instanceof ObjectMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.OBJECT);
         ObjectMessage objMsg = (ObjectMessage)msg;
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

         theProducer.setDeliveryMode(DeliveryMode.PERSISTENT);

         Message m = sessSend.createMessage();
         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);
View Full Code Here

      p.send(bfm);

      MessageConsumer cons = s.createConsumer(queue);
      c.start();

      BytesMessage bm = (BytesMessage)cons.receive();
      assertNotNull(bm);

      c.close();
   }
View Full Code Here

         recv.getStringProperty("String").equals("31415926535897932384626433832795"));
   }
   public void testBytesMessage() throws Exception
   {
      log.info("+++ testBytesMessage");
      BytesMessage sent = session.createBytesMessage();
      sent.writeBoolean(true);
      sent.writeByte((byte) 1);
      byte[] testBytes = "Bytes".getBytes();
      sent.writeBytes(testBytes);
      sent.writeChar('c');
      sent.writeShort((short) 31415);
      sent.writeInt(314159);
      sent.writeLong(3141592653589793238L);
      sent.writeDouble(3.1415926535897932384626433832795);
      sent.writeFloat(3.141f);
      sent.writeObject("31415926535897932384626433832795");
      sent.writeUTF("31415926535897932384626433832795");

      BytesMessage recv = (BytesMessage) sendRecMsg(sent);
      log.debug("recv: "+recv);
      assertTrue("Boolean == true", recv.readBoolean() == true);
      assertTrue("Byte == 1", recv.readByte() == 1);
      byte[] bytes = new byte[testBytes.length];
      recv.readBytes(bytes);
      assertTrue("Bytes == Bytes[]",
         Arrays.equals(bytes, testBytes));
      assertTrue("Char == c", recv.readChar() == 'c');
      assertTrue("Short == 314159", recv.readShort() == 31415);
      assertTrue("Int == 314159", recv.readInt() == 314159);
      assertTrue("Long == 3141592653589793238L",
         recv.readLong() == 3141592653589793238L);
      assertTrue("Double == 3.1415926535897932384626433832795",
         recv.readDouble() == 3.1415926535897932384626433832795);
      assertTrue("Float == true", recv.readFloat() == 3.141f);
      assertTrue("Object == 31415926535897932384626433832795",
         recv.readUTF().equals("31415926535897932384626433832795"));
      assertTrue("String == 31415926535897932384626433832795",
         recv.readUTF().equals("31415926535897932384626433832795"));
   }
View Full Code Here

                  QueueSession session = queueConnection.createQueueSession(transacted != TRANS_NONE, Session.AUTO_ACKNOWLEDGE);
                  Queue queue = (Queue)context.lookup(TEST_QUEUE);

                  QueueSender sender = session.createSender(queue);

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     //sender.send(queue, message, persistence, 4, 0);
View Full Code Here

                  TopicPublisher publisher = session.createPublisher(topic);

                  startFlag.await();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
View Full Code Here

                  QueueSession session = queueConnection.createQueueSession(transacted != TRANS_NONE, Session.AUTO_ACKNOWLEDGE);
                  Queue queue = (Queue)context.lookup(TEST_QUEUE);

                  QueueSender sender = session.createSender(queue);

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     sender.send( message, persistence, 4, 0);
View Full Code Here

                  TopicPublisher publisher = session.createPublisher(topic);

                  alignFlag.countDown();
                  alignFlag.await();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
View Full Code Here

               QueueSession session = queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
               Queue queue = (Queue) context.lookup(TEST_QUEUE);

               QueueSender sender = session.createSender(queue);

               BytesMessage message = session.createBytesMessage();
               message.writeBytes(PAYLOAD);
               message.setStringProperty("TEST_NAME", "runQueueSendRollback");
               message.setIntProperty("TEST_PERSISTENCE", persistence);
               message.setBooleanProperty("TEST_EXPLICIT", explicit);
              
               for (int i = 0; i < iterationCount; i++)
               {
                  sender.send(message, persistence, 4, 0);
               }
View Full Code Here

TOP

Related Classes of javax.jms.BytesMessage

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.