@Test public void testBytesMessageToAdaptrisMessage() throws Exception { EmbeddedActiveMq broker = new EmbeddedActiveMq(); MessageTypeTranslatorImp trans = createTranslator(); try { broker.start(); Session session = broker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE); BytesMessage jmsMsg = session.createBytesMessage(); jmsMsg.writeBytes(BYTES); addProperties(jmsMsg); start(trans, session); jmsMsg.reset(); AdaptrisMessage msg = trans.translate(jmsMsg); assertMetadata(msg); assertTrue("Payload is not equal", Arrays.equals(BYTES, msg.getPayload())); } finally { stop(trans); broker.destroy(); } }
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); }
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); } }
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); }  }
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); }  Message translate(AdaptrisMessage msg); AdaptrisMessage translate(Message msg); }
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); }  Message translate(AdaptrisMessage msg); AdaptrisMessage translate(Message msg);  }