use of javax.jms.MessageEOFException in project rabbitmq-jms-client by rabbitmq.
the class RMQBytesMessage method readChar.
/**
* {@inheritDoc}
*/
@Override
public char readChar() throws JMSException {
if (!this.reading)
throw new MessageNotReadableException(NOT_READABLE);
if (this.pos + Bits.NUM_BYTES_IN_CHAR > this.buf.length)
throw new MessageEOFException(MSG_EOF);
char ch = Bits.getChar(this.buf, this.pos);
this.pos += Bits.NUM_BYTES_IN_CHAR;
return ch;
}
use of javax.jms.MessageEOFException in project rabbitmq-jms-client by rabbitmq.
the class RMQBytesMessage method readDouble.
/**
* {@inheritDoc}
*/
@Override
public double readDouble() throws JMSException {
if (!this.reading)
throw new MessageNotReadableException(NOT_READABLE);
if (this.pos + Bits.NUM_BYTES_IN_DOUBLE > this.buf.length)
throw new MessageEOFException(MSG_EOF);
double dbl = Bits.getDouble(this.buf, this.pos);
this.pos += Bits.NUM_BYTES_IN_DOUBLE;
return dbl;
}
use of javax.jms.MessageEOFException in project activemq-artemis by apache.
the class JMSMessageTest method testStreamMessage.
public void testStreamMessage() throws Exception {
// Receive a message with the JMS API
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationType);
MessageConsumer consumer = session.createConsumer(destination);
MessageProducer producer = session.createProducer(destination);
// Send the message.
{
StreamMessage message = session.createStreamMessage();
message.writeString("This is a test to see how it works.");
producer.send(message);
}
// Check the message.
{
StreamMessage message = (StreamMessage) consumer.receive(1000);
assertNotNull(message);
// position.
try {
message.readByte();
fail("Should have received NumberFormatException");
} catch (NumberFormatException e) {
}
assertEquals("This is a test to see how it works.", message.readString());
// position.
try {
message.readByte();
fail("Should have received MessageEOFException");
} catch (MessageEOFException e) {
}
}
assertNull(consumer.receiveNoWait());
}
use of javax.jms.MessageEOFException in project activemq-artemis by apache.
the class JMSMessageTest method testBytesMessage.
public void testBytesMessage() throws Exception {
// Receive a message with the JMS API
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationType);
MessageConsumer consumer = session.createConsumer(destination);
MessageProducer producer = session.createProducer(destination);
// Send the message
{
BytesMessage message = session.createBytesMessage();
message.writeBoolean(true);
producer.send(message);
}
// Check the message
{
BytesMessage message = (BytesMessage) consumer.receive(1000);
assertNotNull(message);
assertTrue(message.readBoolean());
try {
message.readByte();
fail("Expected exception not thrown.");
} catch (MessageEOFException e) {
}
}
assertNull(consumer.receiveNoWait());
}
use of javax.jms.MessageEOFException in project activemq-artemis by apache.
the class ActiveMQStreamMessageTest method doReadTypeFromEmptyMessage.
// Private -------------------------------------------------------
private void doReadTypeFromEmptyMessage(final TypeReader reader) throws Exception {
ActiveMQStreamMessage message = new ActiveMQStreamMessage();
message.reset();
try {
reader.readType(message);
Assert.fail("MessageEOFException");
} catch (MessageEOFException e) {
}
}
Aggregations