Search in sources :

Example 6 with MessageTypeTranslatorImp

use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.

the class MessageTypeTranslatorCase method testMoveJmsHeadersAdaptrisMessageToJmsMessage.

@Test
public void testMoveJmsHeadersAdaptrisMessageToJmsMessage() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator().withMoveJmsHeaders(true);
    try {
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        addMetadata(msg);
        addRedundantJmsHeaders(msg);
        start(trans, session);
        Message jmsMsg = trans.translate(msg);
        assertEquals(msg.getMetadataValue(JMS_TYPE), jmsMsg.getJMSType());
        assertNotSame(msg.getMetadataValue(JMS_CORRELATION_ID), jmsMsg.getJMSCorrelationID());
        assertNotSame(msg.getMetadataValue(JMS_TIMESTAMP), jmsMsg.getJMSTimestamp());
        assertNotSame(msg.getMetadataValue(JMS_REDELIVERED), jmsMsg.getJMSPriority());
        assertNotSame(msg.getMetadataValue(JMS_MESSAGE_ID), jmsMsg.getJMSMessageID());
        assertNotSame(msg.getMetadataValue(JMS_EXPIRATION), jmsMsg.getJMSExpiration());
        assertNotSame(msg.getMetadataValue(JMS_DELIVERY_MODE), jmsMsg.getJMSDeliveryMode());
        assertJmsProperties(jmsMsg);
    } finally {
        stop(trans);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Example 7 with MessageTypeTranslatorImp

use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.

the class MessageTypeTranslatorCase method testMoveMetadataAdaptrisMessageToJmsMessage.

@Test
public void testMoveMetadataAdaptrisMessageToJmsMessage() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator();
    try {
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        addMetadata(msg);
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        start(trans, session);
        Message jmsMsg = trans.translate(msg);
        assertJmsProperties(jmsMsg);
    } finally {
        stop(trans);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Example 8 with MessageTypeTranslatorImp

use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.

the class MessageTypeTranslatorCase method testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter.

@Test
public void testMoveMetadata_JmsMessageToAdaptrisMessage_WithFilter() throws Exception {
    MessageTypeTranslatorImp trans = createTranslator();
    RegexMetadataFilter regexp = new RegexMetadataFilter();
    regexp.addExcludePattern("IntegerMetadataKey");
    trans.setMetadataFilter(regexp);
    try {
        Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Message jmsMsg = createMessage(session);
        addProperties(jmsMsg);
        start(trans, session);
        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertMetadata(msg, new MetadataElement(STRING_METADATA, STRING_VALUE));
        assertMetadata(msg, new MetadataElement(BOOLEAN_METADATA, BOOLEAN_VALUE));
        assertFalse(msg.containsKey(INTEGER_METADATA));
    } finally {
        stop(trans);
    }
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) Session(javax.jms.Session) Test(org.junit.Test)

Example 9 with MessageTypeTranslatorImp

use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.

the class BlobMessageTranslatorTest method testBug895.

@Test
public void testBug895() throws Exception {
    MessageTypeTranslatorImp trans = new BlobMessageTranslator();
    JmsConnection conn = null;
    try {
        conn = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation());
        start(conn);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        msg.addMetadata(JmsConstants.JMS_PRIORITY, "9");
        msg.addMetadata(JmsConstants.JMS_TYPE, "idaho");
        Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        trans.setMoveJmsHeaders(true);
        trans.registerSession(session);
        trans.registerMessageFactory(new DefaultMessageFactory());
        start(trans);
        Message jmsMsg = trans.translate(msg);
        assertNotSame("JMS Priorities should be different", jmsMsg.getJMSPriority(), 9);
        assertEquals("JMSType should be equal", "idaho", jmsMsg.getJMSType());
    } finally {
        stop(trans);
        stop(conn);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) JmsConnection(com.adaptris.core.jms.JmsConnection) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.ActiveMQSession) Test(org.junit.Test)

Example 10 with MessageTypeTranslatorImp

use of com.adaptris.core.jms.MessageTypeTranslatorImp in project interlok by adaptris.

the class BlobMessageTranslatorTest method testMoveMetadataJmsMessageToAdaptrisMessage.

@Test
public void testMoveMetadataJmsMessageToAdaptrisMessage() 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);
        addProperties(jmsMsg);
        trans.registerSession(session);
        trans.registerMessageFactory(new DefaultMessageFactory());
        start(trans);
        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertMetadata(msg);
    } finally {
        stop(trans);
        stop(conn);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Message(javax.jms.Message) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MessageTypeTranslatorImp(com.adaptris.core.jms.MessageTypeTranslatorImp) JmsConnection(com.adaptris.core.jms.JmsConnection) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.ActiveMQSession) Test(org.junit.Test)

Aggregations

MessageTypeTranslatorImp (com.adaptris.core.jms.MessageTypeTranslatorImp)17 Test (org.junit.Test)17 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)13 Message (javax.jms.Message)13 Session (javax.jms.Session)13 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)4 JmsConnection (com.adaptris.core.jms.JmsConnection)4 ActiveMQSession (org.apache.activemq.ActiveMQSession)4 RegexMetadataFilter (com.adaptris.core.metadata.RegexMetadataFilter)3 RemoveAllMetadataFilter (com.adaptris.core.metadata.RemoveAllMetadataFilter)2 MetadataElement (com.adaptris.core.MetadataElement)1 StandaloneProducer (com.adaptris.core.StandaloneProducer)1 NoOpMetadataFilter (com.adaptris.core.metadata.NoOpMetadataFilter)1