Java 类javax.jms.MessageEOFException 实例源码
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:ffmq
文件:MessageTools.java
private static AbstractMessage duplicateStreamMessage( StreamMessage srcMessage ) throws JMSException
{
StreamMessageImpl copy = new StreamMessageImpl();
copyHeaders(srcMessage,copy);
srcMessage.reset();
try
{
while (true)
copy.writeObject(srcMessage.readObject());
}
catch (MessageEOFException e)
{
// Complete
}
return copy;
}
项目:ffmq
文件:BytesMessageImplTest.java
public void testClearBody() throws Exception
{
BytesMessageImpl msg;
byte[] dummy = { (byte)1 , (byte)2 , (byte)3 };
msg = new BytesMessageImpl();
msg.writeBytes(dummy);
msg.reset();
assertEquals(true,msg.readBoolean());
assertEquals(true,msg.readBoolean());
assertEquals(true,msg.readBoolean());
msg.clearBody();
msg.writeBytes(dummy);
msg.reset();
assertEquals(true,msg.readBoolean());
assertEquals(true,msg.readBoolean());
assertEquals(true,msg.readBoolean());
msg.clearBody();
msg.writeBytes(dummy);
msg.clearBody();
msg.reset();
try { msg.readByte(); fail("Should have failed"); } catch (MessageEOFException e) { /* OK */ }
}
项目:andes
文件:BytesMessageTest.java
public void testEOFByte() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeByte((byte)1);
bm.reset();
bm.readByte();
// should throw
bm.readByte();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFUnsignedByte() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeByte((byte)1);
bm.reset();
bm.readByte();
// should throw
bm.readUnsignedByte();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFBoolean() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeBoolean(true);
bm.reset();
bm.readBoolean();
// should throw
bm.readBoolean();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFChar() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeChar('A');
bm.reset();
bm.readChar();
// should throw
bm.readChar();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFDouble() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeDouble(1.3d);
bm.reset();
bm.readDouble();
// should throw
bm.readDouble();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFFloat() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeFloat(1.3f);
bm.reset();
bm.readFloat();
// should throw
bm.readFloat();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFInt() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeInt(99);
bm.reset();
bm.readInt();
// should throw
bm.readInt();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFLong() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeLong(4L);
bm.reset();
bm.readLong();
// should throw
bm.readLong();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFShort() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeShort((short)4);
bm.reset();
bm.readShort();
// should throw
bm.readShort();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:BytesMessageTest.java
public void testEOFUnsignedShort() throws Exception
{
try
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeShort((short)4);
bm.reset();
bm.readUnsignedShort();
// should throw
bm.readUnsignedShort();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFByte() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeByte((byte)1);
bm.reset();
bm.readByte();
// should throw
bm.readByte();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFBoolean() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeBoolean(true);
bm.reset();
bm.readBoolean();
// should throw
bm.readBoolean();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFChar() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeChar('A');
bm.reset();
bm.readChar();
// should throw
bm.readChar();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFDouble() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeDouble(1.3d);
bm.reset();
bm.readDouble();
// should throw
bm.readDouble();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFFloat() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeFloat(1.3f);
bm.reset();
bm.readFloat();
// should throw
bm.readFloat();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFInt() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeInt(99);
bm.reset();
bm.readInt();
// should throw
bm.readInt();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFLong() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeLong(4L);
bm.reset();
bm.readLong();
// should throw
bm.readLong();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:andes
文件:StreamMessageTest.java
public void testEOFShort() throws Exception
{
try
{
JMSStreamMessage bm = TestMessageHelper.newJMSStreamMessage();
bm.writeShort((short)4);
bm.reset();
bm.readShort();
// should throw
bm.readShort();
fail("expected exception did not occur");
}
catch (MessageEOFException m)
{
// ok
}
catch (Exception e)
{
fail("expected MessageEOFException, got " + e);
}
}
项目:carbon-business-messaging
文件:Utils.java
/**
* A stream message can have java primitives plus objects, as its content. This method is used
* for getting the valid message content from the stream.
*
* @param streamMessage - input message
* @param sb - a string builder to build the whole message content
* @return - complete message content inside the stream message
* @throws JMSException
*/
private static String getContentFromStreamMessage(StreamMessage streamMessage,
StringBuilder sb) throws JMSException {
boolean eofReached = false;
while (!eofReached) {
try {
Object obj = streamMessage.readObject();
// obj could be null if the wire type is AbstractBytesTypedMessage.NULL_STRING_TYPE
if (null != obj) {
sb.append(obj.toString()).append(", ");
}
} catch (MessageEOFException ex) {
eofReached = true;
}
}
return StringEscapeUtils.escapeHtml(sb.toString());
}
项目:qpid-jms
文件:JmsStreamMessageTest.java
@Test
public void testClearBodyOnNewMessageRemovesExistingValues() throws Exception {
JmsStreamMessage streamMessage = factory.createStreamMessage();
streamMessage.writeBoolean(true);
streamMessage.clearBody();
streamMessage.writeBoolean(false);
streamMessage.reset();
// check we get only the value added after the clear
assertFalse("expected value added after the clear", streamMessage.readBoolean());
try {
streamMessage.readBoolean();
fail("Expected exception to be thrown");
} catch (MessageEOFException meofe) {
// expected
}
}
项目:qpid-jms
文件:AmqpJmsStreamMessageFacadeTest.java
@Test
public void testPopFullyReadListThrowsMEOFE() throws Exception {
Message message = Message.Factory.create();
List<Object> list = new ArrayList<Object>();
list.add(Boolean.FALSE);
message.setBody(new AmqpSequence(list));
AmqpJmsStreamMessageFacade amqpStreamMessageFacade = createReceivedStreamMessageFacade(createMockAmqpConsumer(), message);
assertEquals("Unexpected value retrieved", Boolean.FALSE, amqpStreamMessageFacade.peek());
amqpStreamMessageFacade.pop();
try {
amqpStreamMessageFacade.pop();
fail("expected exception to be thrown");
} catch (MessageEOFException meofe) {
// expected
}
}
项目:daq-eclipse
文件:JMSExceptionSupport.java
public static MessageEOFException createMessageEOFException(Exception cause) {
String msg = cause.getMessage();
if (msg == null || msg.length() == 0) {
msg = cause.toString();
}
MessageEOFException exception = new MessageEOFException(msg);
exception.setLinkedException(cause);
exception.initCause(cause);
return exception;
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:SimpleJMSStreamMessage.java
@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("");
}
}
项目:activemq-artemis
文件:ActiveMQStreamMessageTest.java
private void doReadTypeFromEmptyMessage(final TypeReader reader) throws Exception {
ActiveMQStreamMessage message = new ActiveMQStreamMessage();
message.reset();
try {
reader.readType(message);
Assert.fail("MessageEOFException");
} catch (MessageEOFException e) {
}
}
项目:activemq-artemis
文件:ActiveMQStreamMessage.java
public ActiveMQStreamMessage(final StreamMessage foreign, final ClientSession session) throws JMSException {
super(foreign, ActiveMQStreamMessage.TYPE, session);
foreign.reset();
try {
while (true) {
Object obj = foreign.readObject();
writeObject(obj);
}
} catch (MessageEOFException e) {
// Ignore
}
}
项目:activemq-artemis
文件:ActiveMQBytesMessage.java
@Override
public boolean readBoolean() throws JMSException {
checkRead();
try {
return bytesReadBoolean(message.getBodyBuffer());
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
项目:activemq-artemis
文件:ActiveMQBytesMessage.java
@Override
public byte readByte() throws JMSException {
checkRead();
try {
return bytesReadByte(message.getBodyBuffer());
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
项目:activemq-artemis
文件:ActiveMQBytesMessage.java
@Override
public int readUnsignedByte() throws JMSException {
checkRead();
try {
return bytesReadUnsignedByte(message.getBodyBuffer());
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
项目:activemq-artemis
文件:ActiveMQBytesMessage.java
@Override
public short readShort() throws JMSException {
checkRead();
try {
return bytesReadShort(message.getBodyBuffer());
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}
项目:activemq-artemis
文件:ActiveMQBytesMessage.java
@Override
public int readUnsignedShort() throws JMSException {
checkRead();
try {
return bytesReadUnsignedShort(message.getBodyBuffer());
} catch (IndexOutOfBoundsException e) {
throw new MessageEOFException("");
}
}