use of org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage in project activemq-artemis by apache.
the class AbstractPersistentStatTestSupport method createMessage.
/**
* Generate random messages between 100 bytes and maxMessageSize
*
* @param session
* @return
* @throws JMSException
* @throws ActiveMQException
*/
protected BytesMessage createMessage(int count, Session session, int maxMessageSize, AtomicLong publishedMessageSize) throws JMSException, ActiveMQException {
final ActiveMQBytesMessage message = (ActiveMQBytesMessage) session.createBytesMessage();
final Random randomSize = new Random();
int size = randomSize.nextInt((maxMessageSize - 100) + 1) + 100;
final byte[] data = new byte[size];
final Random rng = new Random();
rng.nextBytes(data);
message.writeBytes(data);
if (publishedMessageSize != null) {
publishedMessageSize.addAndGet(message.getCoreMessage().getPersistentSize());
}
return message;
}
use of org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage in project activemq-artemis by apache.
the class MessageHeaderTest method testCopyOnForeignBytesMessage.
@Test
public void testCopyOnForeignBytesMessage() throws JMSException {
ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
ClientSession session = new FakeSession(clientMessage);
BytesMessage foreignBytesMessage = new SimpleJMSBytesMessage();
for (int i = 0; i < 20; i++) {
foreignBytesMessage.writeByte((byte) i);
}
ActiveMQBytesMessage copy = new ActiveMQBytesMessage(foreignBytesMessage, session);
foreignBytesMessage.reset();
copy.reset();
MessageHeaderTestBase.ensureEquivalent(foreignBytesMessage, copy);
}
Aggregations