class BytesMessageTranslator extends MessageTypeTranslatorImp {

  public Message translate(AdaptrisMessage msg) throws JMSException {
    BytesMessage jmsMsg = session.createBytesMessage();
    if (msg.getSize() > streamThreshold()) {
      try (InputStream in = msg.getInputStream(); BytesMessageOutputStream out = new BytesMessageOutputStream(jmsMsg)) {
        StreamUtil.copyAndClose(in, out);
      }
      catch (IOException e) {
        throw JmsUtils.wrapJMSException(e);
      }
    }
    else {
      jmsMsg.writeBytes(msg.getPayload());
    }
    return helper.moveMetadata(msg, jmsMsg);
  }

}