• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MessageNotReadableException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.jms.MessageNotReadableException的典型用法代码示例。如果您正苦于以下问题:Java MessageNotReadableException类的具体用法?Java MessageNotReadableException怎么用?Java MessageNotReadableException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageNotReadableException类属于javax.jms包,在下文中一共展示了MessageNotReadableException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readByte

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public byte readByte() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }

   try {
      Object value = content.get(position);
      offset = 0;
      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).byteValue();
      } else if (value instanceof String) {
         byte result = Byte.parseByte((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SimpleJMSStreamMessage.java


示例2: readChar

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public char readChar() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Character) {
         position++;
         return ((Character) value).charValue();
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:SimpleJMSStreamMessage.java


示例3: readFloat

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public float readFloat() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Float) {
         position++;
         return ((Float) value).floatValue();
      } else if (value instanceof String) {
         float result = Float.parseFloat((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SimpleJMSStreamMessage.java


示例4: send

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
void send(int count) throws JMSException
{
    // create a publisher
    MessageProducer producer = _session.createProducer(_destination);
    for (int i = 0; i < count; i++)
    {
        BytesMessage msg = _session.createBytesMessage();

        try
        {
            msg.readFloat();
            Assert.fail("Message should not be readable");
        }
        catch (MessageNotReadableException mnwe)
        {
            // normal execution
        }

        byte[] data = ("Message " + i).getBytes();
        msg.writeBytes(data);
        messages.add(data);
        producer.send(msg);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:25,代码来源:BytesMessageTest.java


示例5: testNotReadableOnCreationWithNull

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
/**
 * Tests that on creation a call to getBodyLength() throws an exception
 * if null was passed in during creation
 */
public void testNotReadableOnCreationWithNull() throws Exception
{
    try
    {
        JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
        bm.getBodyLength();
        fail("expected exception did not occur");
    }
    catch (MessageNotReadableException m)
    {
        // ok
    }
    catch (Exception e)
    {
        fail("expected MessageNotReadableException, got " + e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:22,代码来源:BytesMessageTest.java


示例6: testNotReadableOnCreationWithNull

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
/**
 * Tests that on creation a call to getBodyLength() throws an exception
 * if null was passed in during creation
 */
public void testNotReadableOnCreationWithNull() throws Exception
{
    try
    {
        JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
        bm.readByte();
        fail("expected exception did not occur");
    }
    catch (MessageNotReadableException m)
    {
        // ok
    }
    catch (Exception e)
    {
        fail("expected MessageNotReadableException, got " + e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:22,代码来源:StreamMessageTest.java


示例7: testClearBody

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Test
public void testClearBody() throws JMSException, IOException {
    JmsTextMessage textMessage = factory.createTextMessage();
    textMessage.setText("string");
    textMessage.clearBody();
    assertFalse(textMessage.isReadOnlyBody());
    assertNull(textMessage.getText());
    try {
        textMessage.setText("String");
        textMessage.getText();
    } catch (MessageNotWriteableException mnwe) {
        fail("should be writeable");
    } catch (MessageNotReadableException mnre) {
        fail("should be readable");
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsTextMessageTest.java


示例8: testReadOnlyBody

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Test
public void testReadOnlyBody() throws JMSException {
    JmsTextMessage textMessage = factory.createTextMessage();
    textMessage.setText("test");
    textMessage.setReadOnlyBody(true);
    try {
        textMessage.getText();
    } catch (MessageNotReadableException e) {
        fail("should be readable");
    }
    try {
        textMessage.setText("test");
        fail("should throw exception");
    } catch (MessageNotWriteableException mnwe) {
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:17,代码来源:JmsTextMessageTest.java


示例9: testGetBodyLengthOnClearedReceivedMessageThrowsMessageNotReadableException

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
/**
 * Test that attempting to call {@link BytesMessage#getBodyLength()} on a received message after calling
 * {@link BytesMessage#clearBody()} causes {@link MessageNotReadableException} to be thrown due to being write-only.
 *
 * @throws Exception if an error occurs during the test.
 */
@Test
public void testGetBodyLengthOnClearedReceivedMessageThrowsMessageNotReadableException() throws Exception {
    byte[] content = "myBytesData".getBytes();
    JmsTestBytesMessageFacade facade = new JmsTestBytesMessageFacade(content);

    JmsBytesMessage bytesMessage = new JmsBytesMessage(facade);
    bytesMessage.onDispatch();
    assertEquals("Unexpected message length", content.length, bytesMessage.getBodyLength());
    bytesMessage.clearBody();

    try {
        bytesMessage.getBodyLength();
        fail("expected exception to be thrown");
    } catch (MessageNotReadableException mnre) {
        // expected
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:24,代码来源:JmsBytesMessageTest.java


示例10: testUnreadablePrioirtyIsStillEnqueued

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Test
public void testUnreadablePrioirtyIsStillEnqueued() throws JMSException {
    JmsInboundMessageDispatch message = createEnvelopeWithMessageThatCannotReadPriority();
    queue.enqueue(createEnvelope(9));
    queue.enqueue(message);
    queue.enqueue(createEnvelope(1));

    JmsInboundMessageDispatch envelope = queue.peek();
    assertEquals(9, envelope.getMessage().getJMSPriority());
    queue.dequeueNoWait();
    envelope = queue.peek();
    try {
        envelope.getMessage().getJMSPriority();
        fail("Unreadable priority message should sit at default level");
    } catch (MessageNotReadableException mnre) {}
    queue.dequeueNoWait();
    envelope = queue.peek();
    assertEquals(1, envelope.getMessage().getJMSPriority());
    queue.dequeueNoWait();

    assertTrue(queue.isEmpty());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:23,代码来源:PriorityMessageQueueTest.java


示例11: testClearBody

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
/**
 * Test clear body
 */
@Test
public void testClearBody() throws JMSException, IOException {

    SQSBytesMessage msg = new SQSBytesMessage();

    byte[] byteArray = new byte[] { 1, 0, 'a', 65 };
    msg.writeBytes(byteArray);

    msg.clearBody();

    byte[] readByteArray = new byte[4];

    /*
     * Verify message is in write-only mode
     */
    try {
        msg.readBytes(readByteArray);
    } catch(MessageNotReadableException exception) {
        assertEquals("Message is not readable", exception.getMessage());
    }

    msg.writeBytes(byteArray);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:27,代码来源:SQSBytesMessageTest.java


示例12: testClearBody

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
public void testClearBody() throws JMSException, IOException {
   ActiveMQTextMessage textMessage = new ActiveMQTextMessage();
   textMessage.setText("string");
   textMessage.clearBody();
   assertFalse(textMessage.isReadOnlyBody());
   assertNull(textMessage.getText());
   try {
      textMessage.setText("String");
      textMessage.getText();
   } catch (MessageNotWriteableException mnwe) {
      fail("should be writeable");
   } catch (MessageNotReadableException mnre) {
      fail("should be readable");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQTextMessageTest.java


示例13: testReadOnlyBody

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
public void testReadOnlyBody() throws JMSException {
   ActiveMQTextMessage textMessage = new ActiveMQTextMessage();
   textMessage.setText("test");
   textMessage.setReadOnlyBody(true);
   try {
      textMessage.getText();
   } catch (MessageNotReadableException e) {
      fail("should be readable");
   }
   try {
      textMessage.setText("test");
      fail("should throw exception");
   } catch (MessageNotWriteableException mnwe) {
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQTextMessageTest.java


示例14: readBoolean

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public boolean readBoolean() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }

   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Boolean) {
         position++;
         return ((Boolean) value).booleanValue();
      } else if (value instanceof String) {
         boolean result = Boolean.valueOf((String) value).booleanValue();
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:SimpleJMSStreamMessage.java


示例15: readShort

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public short readShort() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).shortValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).shortValue();
      } else if (value instanceof String) {
         short result = Short.parseShort((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:29,代码来源:SimpleJMSStreamMessage.java


示例16: readInt

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public int readInt() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).intValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).intValue();
      } else if (value instanceof Integer) {
         position++;
         return ((Integer) value).intValue();
      } else if (value instanceof String) {
         int result = Integer.parseInt((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:SimpleJMSStreamMessage.java


示例17: readLong

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public long readLong() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).longValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).longValue();
      } else if (value instanceof Integer) {
         position++;
         return ((Integer) value).longValue();
      } else if (value instanceof Long) {
         position++;
         return ((Long) value).longValue();
      } else if (value instanceof String) {
         long result = Long.parseLong((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:SimpleJMSStreamMessage.java


示例18: readDouble

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public double readDouble() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Float) {
         position++;
         return ((Float) value).doubleValue();
      } else if (value instanceof Double) {
         position++;
         return ((Double) value).doubleValue();
      } else if (value instanceof String) {
         double result = Double.parseDouble((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:29,代码来源:SimpleJMSStreamMessage.java


示例19: readObject

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
@Override
public Object readObject() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      position++;
      offset = 0;

      return value;
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:SimpleJMSStreamMessage.java


示例20: checkRead

import javax.jms.MessageNotReadableException; //导入依赖的package包/类
/**
 * Check the message is readable
 *
 * @throws javax.jms.JMSException when not readable
 */
private void checkRead() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("readByte while the buffer is writeonly");
   }

   // We have just received/reset() the message, and the client is trying to
   // read it
   if (istream == null || m == null) {
      istream = new ByteArrayInputStream(internalArray);
      m = new DataInputStream(istream);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:SimpleJMSBytesMessage.java



注:本文中的javax.jms.MessageNotReadableException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FilterPackageInfo类代码示例发布时间:2022-05-23
下一篇:
Java ResourceAllocationException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap