use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveMetadataAdaptrisMessageToJmsMessage.
@Test
public void testMoveMetadataAdaptrisMessageToJmsMessage() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
addMetadata(msg);
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
start(trans);
Message jmsMsg = trans.translate(msg);
assertJmsProperties(jmsMsg);
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.
the class BlobMessageTranslatorTest method testMoveJmsHeadersJmsMessageToAdaptrisMessage.
@Test
public void testMoveJmsHeadersJmsMessageToAdaptrisMessage() throws Exception {
MessageTypeTranslatorImp trans = new BlobMessageTranslator();
JmsConnection conn = null;
try {
conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
start(conn);
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Message jmsMsg = createMessage(session);
jmsMsg.setJMSCorrelationID("ABC");
jmsMsg.setJMSDeliveryMode(1);
jmsMsg.setJMSPriority(4);
addProperties(jmsMsg);
long timestamp = System.currentTimeMillis();
jmsMsg.setJMSTimestamp(timestamp);
trans.registerSession(session);
trans.registerMessageFactory(new DefaultMessageFactory());
trans.setMoveJmsHeaders(true);
start(trans);
AdaptrisMessage msg = trans.translate(jmsMsg);
assertMetadata(msg);
assertEquals("ABC", msg.getMetadataValue(JmsConstants.JMS_CORRELATION_ID));
assertEquals("1", msg.getMetadataValue(JmsConstants.JMS_DELIVERY_MODE));
assertEquals("4", msg.getMetadataValue(JmsConstants.JMS_PRIORITY));
assertEquals(String.valueOf(timestamp), msg.getMetadataValue(JmsConstants.JMS_TIMESTAMP));
} finally {
stop(trans);
stop(conn);
}
}
use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.
the class EmbeddedActiveMq method getFailoverJmsConnection.
public FailoverJmsConnection getFailoverJmsConnection(boolean isPtp) throws Exception {
FailoverJmsConnection result = new FailoverJmsConnection();
if (!isPtp) {
JmsConnection c = new JmsConnection(new BasicActiveMqImplementation(DEF_URL_PREFIX + "9999"));
result.addConnection(c);
result.addConnection(getJmsConnection(new BasicActiveMqImplementation(), true));
} else {
JmsConnection c = new JmsConnection(new BasicActiveMqImplementation(DEF_URL_PREFIX + "9999"));
result.addConnection(c);
result.addConnection(getJmsConnection(new BasicActiveMqImplementation(), true));
}
return result;
}
use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.
the class ActiveMqPasPollingConsumerTest method createStandalone.
private StandaloneConsumer createStandalone(EmbeddedActiveMq mq, String threadName, String destinationName) throws Exception {
PasPollingConsumer consumer = new PasPollingConsumer().withTopic(destinationName);
consumer.setPoller(new Sometime());
JmsConnection c = mq.getJmsConnection();
consumer.setVendorImplementation(c.getVendorImplementation());
consumer.setClientId(c.getClientId());
consumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
consumer.setReacquireLockBetweenMessages(true);
consumer.setAdditionalDebug(true);
consumer.setReceiveTimeout(new TimeInterval(Integer.valueOf(new Random().nextInt(100) + 100).longValue(), TimeUnit.MILLISECONDS));
StandaloneConsumer sc = new StandaloneConsumer(consumer);
return sc;
}
use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.
the class AdvancedActiveMqConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JmsConnection connection = new JmsConnection();
PtpConsumer producer = new PtpConsumer();
producer.setQueue("destination");
UrlVendorImplementation vendorImpl = createImpl();
vendorImpl.setBrokerUrl(BasicActiveMqImplementationTest.PRIMARY);
connection.setUserName("BrokerUsername");
connection.setPassword("BrokerPassword");
connection.setVendorImplementation(vendorImpl);
StandaloneConsumer result = new StandaloneConsumer();
result.setConnection(connection);
result.setConsumer(producer);
return result;
}
Aggregations