List of usage examples for javax.jms BytesMessage getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.apache.axis2.transport.jms.JMSUtils.java
/** * Return the body length in bytes for a bytes message * @param bMsg the JMS BytesMessage/* ww w.j av a 2 s. c o m*/ * @return length of body in bytes */ public static long getBodyLength(BytesMessage bMsg) { try { Method mtd = bMsg.getClass().getMethod("getBodyLength", NOARGS); if (mtd != null) { return (Long) mtd.invoke(bMsg, NOPARMS); } } catch (Exception e) { // JMS 1.0 if (log.isDebugEnabled()) { log.debug("Error trying to determine JMS BytesMessage body length", e); } } // if JMS 1.0 long length = 0; try { byte[] buffer = new byte[2048]; bMsg.reset(); for (int bytesRead = bMsg.readBytes(buffer); bytesRead != -1; bytesRead = bMsg.readBytes(buffer)) { length += bytesRead; } } catch (JMSException ignore) { } return length; }