use of org.apache.activemq.command.ActiveMQObjectMessage in project activemq-artemis by apache.
the class ActiveMQObjectMessageTest method createObject.
@Override
public Object createObject() throws Exception {
ActiveMQObjectMessage info = new ActiveMQObjectMessage();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ActiveMQObjectMessage in project activemq-artemis by apache.
the class ActiveMQObjectMessageTest method createObject.
@Override
public Object createObject() throws Exception {
ActiveMQObjectMessage info = new ActiveMQObjectMessage();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ActiveMQObjectMessage in project activemq-artemis by apache.
the class ActiveMQObjectMessageTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ActiveMQObjectMessage info = (ActiveMQObjectMessage) object;
}
use of org.apache.activemq.command.ActiveMQObjectMessage in project activemq-artemis by apache.
the class ActiveMQObjectMessageTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ActiveMQObjectMessage info = (ActiveMQObjectMessage) object;
}
use of org.apache.activemq.command.ActiveMQObjectMessage in project activemq-artemis by apache.
the class ObjectMessageNotSerializableTest method testSendNotSerializeableObjectMessageOverTcp.
public void testSendNotSerializeableObjectMessageOverTcp() throws Exception {
final ActiveMQDestination destination = new ActiveMQTopic("testTopic");
final MyObject obj = new MyObject("A message");
final CountDownLatch consumerStarted = new CountDownLatch(3);
final Vector<Throwable> exceptions = new Vector<>();
Thread vmConsumerThread = new Thread("Consumer Thread") {
@Override
public void run() {
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
factory.setOptimizedMessageDispatch(true);
factory.setObjectMessageSerializationDefered(true);
factory.setCopyMessageOnSend(false);
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination);
connection.start();
consumerStarted.countDown();
ActiveMQObjectMessage message = (ActiveMQObjectMessage) consumer.receive(30000);
if (message != null) {
MyObject object = (MyObject) message.getObject();
LOG.info("Got message " + object.getMessage());
numReceived.incrementAndGet();
}
consumer.close();
} catch (Throwable ex) {
exceptions.add(ex);
}
}
};
vmConsumerThread.start();
Thread tcpConsumerThread = new Thread("Consumer Thread") {
@Override
public void run() {
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
factory.setOptimizedMessageDispatch(true);
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination);
connection.start();
consumerStarted.countDown();
ActiveMQObjectMessage message = (ActiveMQObjectMessage) consumer.receive(30000);
if (message != null) {
MyObject object = (MyObject) message.getObject();
LOG.info("Got message " + object.getMessage());
numReceived.incrementAndGet();
assertEquals("readObject called", 1, object.getReadObjectCalled());
}
consumer.close();
} catch (Throwable ex) {
exceptions.add(ex);
}
}
};
tcpConsumerThread.start();
Thread notherVmConsumerThread = new Thread("Consumer Thread") {
@Override
public void run() {
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
factory.setOptimizedMessageDispatch(true);
factory.setObjectMessageSerializationDefered(true);
factory.setCopyMessageOnSend(false);
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination);
connection.start();
consumerStarted.countDown();
ActiveMQObjectMessage message = (ActiveMQObjectMessage) consumer.receive(30000);
if (message != null) {
MyObject object = (MyObject) message.getObject();
LOG.info("Got message " + object.getMessage());
numReceived.incrementAndGet();
}
consumer.close();
} catch (Throwable ex) {
exceptions.add(ex);
}
}
};
notherVmConsumerThread.start();
Thread producingThread = new Thread("Producing Thread") {
@Override
public void run() {
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
factory.setOptimizedMessageDispatch(true);
factory.setObjectMessageSerializationDefered(true);
factory.setCopyMessageOnSend(false);
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
ActiveMQObjectMessage message = (ActiveMQObjectMessage) session.createObjectMessage();
message.setObject(obj);
producer.send(message);
producer.close();
} catch (Throwable ex) {
exceptions.add(ex);
}
}
};
assertTrue("consumers started", consumerStarted.await(10, TimeUnit.SECONDS));
producingThread.start();
vmConsumerThread.join();
tcpConsumerThread.join();
notherVmConsumerThread.join();
producingThread.join();
assertEquals("writeObject called", 1, obj.getWriteObjectCalled());
assertEquals("readObject called", 0, obj.getReadObjectCalled());
assertEquals("readObjectNoData called", 0, obj.getReadObjectNoDataCalled());
assertEquals("Got expected messages", 3, numReceived.get());
assertTrue("no unexpected exceptions: " + exceptions, exceptions.isEmpty());
}
Aggregations