本文整理汇总了Java中javax.jms.BytesMessage.readByte方法的典型用法代码示例。如果您正苦于以下问题:Java BytesMessage.readByte方法的具体用法?Java BytesMessage.readByte怎么用?Java BytesMessage.readByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.BytesMessage
的用法示例。
在下文中一共展示了BytesMessage.readByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSame
import javax.jms.BytesMessage; //导入方法依赖的package包/类
protected boolean isSame(BytesMessage msg1) throws Exception {
boolean result = false;
((ActiveMQMessage) msg1).setReadOnlyBody(true);
for (int i = 0; i < LARGE_MESSAGE_SIZE; i++) {
result = msg1.readByte() == largeMessageData[i];
if (!result) {
break;
}
}
return result;
}
示例2: castTo
import javax.jms.BytesMessage; //导入方法依赖的package包/类
public static <T> T castTo(Class<T> c, Message message) throws JMSException {
if (message == null) {
throw new MessageFormatRuntimeException("empty body");
}
if (!isBodyAssignableTo(message, c)) {
throw new MessageFormatRuntimeException("the message body cannot be assigned to the specified type "
+ c
+ " and the Message type "
+ StreamMessage.class
+ " cannot be used");
}
if (message instanceof ObjectMessage) {
return c.cast(((ObjectMessage) message).getObject());
} else if (message instanceof MapMessage) {
return c.cast(resolveMapMessage((MapMessage) message));
} else if (message instanceof BytesMessage) {
BytesMessage bytesMessage = (BytesMessage) message;
bytesMessage.reset();
try {
byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = bytesMessage.readByte();
}
return c.cast(bytes);
} finally {
bytesMessage.reset();
}
} else if (message instanceof TextMessage) {
return c.cast(((TextMessage) message).getText());
} else {
throw new MessageFormatRuntimeException("internal error. unknown message type "
+ message.getClass() + " or empty body");
}
}